Initial commit
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.promo.mapper.PromoTurnoverMapper">
|
||||
|
||||
<select id="getAnchorCount" parameterType="Integer" resultType="int">
|
||||
SELECT COUNT(*) FROM tt_user WHERE parent_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="getPlayersTurnover"
|
||||
parameterType="com.ruoyi.promo.domain.param.GetPlayersTurnoverParam"
|
||||
resultType="BigDecimal">
|
||||
SELECT
|
||||
SUM(ABS(total))
|
||||
FROM
|
||||
tt_user_blend_ercash
|
||||
WHERE
|
||||
type = 0
|
||||
<if test="sourceCodes != null and sourceCodes.size() > 0">
|
||||
AND source IN
|
||||
<foreach item="code" collection="sourceCodes" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
AND user_id IN
|
||||
<foreach item="id" index="index" collection="userIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND create_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND create_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getLast10DaysTurnover" parameterType="List" resultType="com.ruoyi.promo.domain.vo.DayTurnoverVO">
|
||||
SELECT
|
||||
date_range.date,
|
||||
IFNULL(SUM(ABS(tt_user_blend_ercash.amount)), 0) AS amount
|
||||
FROM
|
||||
(
|
||||
SELECT CURDATE() - INTERVAL 10 DAY AS date
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 9 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 8 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 7 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 6 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 5 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 4 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 3 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 2 DAY
|
||||
UNION ALL
|
||||
SELECT CURDATE() - INTERVAL 1 DAY
|
||||
) AS date_range
|
||||
LEFT JOIN tt_user_blend_ercash ON DATE(tt_user_blend_ercash.create_time) = date_range.date
|
||||
AND tt_user_blend_ercash.type = '0'
|
||||
<if test="sourceCodes != null and sourceCodes.size() > 0">
|
||||
AND tt_user_blend_ercash.source IN
|
||||
<foreach item="code" collection="sourceCodes" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
AND tt_user_blend_ercash.user_id IN
|
||||
<foreach item="id" collection="userIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
GROUP BY date_range.date
|
||||
</select>
|
||||
|
||||
<select id="getLast10DaysInvite" parameterType="Integer" resultType="com.ruoyi.promo.domain.vo.DayInviteVO">
|
||||
SELECT
|
||||
DATE(date_range.date) AS date,
|
||||
COUNT(tt_user.user_id) AS anchorCount
|
||||
FROM
|
||||
(
|
||||
SELECT CURDATE() - INTERVAL (a.a + 1) DAY AS date
|
||||
FROM
|
||||
(
|
||||
SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
|
||||
) AS a
|
||||
) AS date_range
|
||||
LEFT JOIN tt_user ON DATE(tt_user.create_time) = DATE(date_range.date)
|
||||
AND tt_user.user_type = '02'
|
||||
AND tt_user.parent_id IN
|
||||
(
|
||||
SELECT user_id
|
||||
FROM tt_user
|
||||
WHERE user_type = '01'
|
||||
AND parent_id = #{userId}
|
||||
)
|
||||
GROUP BY DATE(date_range.date)
|
||||
ORDER BY DATE(date_range.date)
|
||||
</select>
|
||||
|
||||
<select id="getAnchorDayTurnover" parameterType="com.ruoyi.promo.domain.dto.AnchorDayTurnoverDTO" resultType="com.ruoyi.promo.domain.vo.AnchorDayTurnoverVO">
|
||||
SELECT
|
||||
daily.user_id,
|
||||
daily.parent_id,
|
||||
daily.nick_name,
|
||||
tu_parent.nick_name AS parent_nick_name,
|
||||
daily.daily_total,
|
||||
daily.date,
|
||||
total.total_by_parent
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
tube.user_id,
|
||||
tu.parent_id,
|
||||
tu.nick_name,
|
||||
SUM(ABS(tube.total)) AS daily_total,
|
||||
DATE(tube.create_time) AS date
|
||||
FROM
|
||||
tt_user_blend_ercash AS tube
|
||||
LEFT JOIN
|
||||
tt_user AS tu ON tube.user_id = tu.user_id
|
||||
LEFT JOIN
|
||||
tt_user AS tu_parent ON tu.parent_id = tu_parent.user_id
|
||||
WHERE
|
||||
tube.type = 0
|
||||
AND tube.user_id IN
|
||||
<foreach item="id" index="index" collection="userIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="sourceCodes != null and sourceCodes.size() > 0">
|
||||
AND tube.source IN
|
||||
<foreach item="code" collection="sourceCodes" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
AND tu.parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="parentNickName != null and parentNickName != ''">
|
||||
AND tu_parent.nick_name like concat('%', #{parentNickName}, '%')
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND date_format(tube.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND date_format(tube.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
GROUP BY
|
||||
tube.user_id, tu.parent_id, DATE(tube.create_time)
|
||||
) AS daily
|
||||
JOIN
|
||||
(
|
||||
SELECT
|
||||
tu.parent_id,
|
||||
SUM(ABS(tube.total)) AS total_by_parent
|
||||
FROM
|
||||
tt_user_blend_ercash AS tube
|
||||
LEFT JOIN
|
||||
tt_user AS tu ON tube.user_id = tu.user_id
|
||||
LEFT JOIN
|
||||
tt_user AS tu_parent ON tu.parent_id = tu_parent.user_id
|
||||
WHERE
|
||||
tube.type = 0
|
||||
AND tube.user_id IN
|
||||
<foreach item="id" index="index" collection="userIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="sourceCodes != null and sourceCodes.size() > 0">
|
||||
AND tube.source IN
|
||||
<foreach item="code" collection="sourceCodes" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
AND tu.parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="parentNickName != null and parentNickName != ''">
|
||||
AND tu_parent.nick_name like concat('%', #{parentNickName}, '%')
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND date_format(tube.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND date_format(tube.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
GROUP BY
|
||||
tu.parent_id
|
||||
) AS total
|
||||
ON
|
||||
daily.parent_id = total.parent_id
|
||||
JOIN
|
||||
tt_user AS tu_parent ON daily.parent_id = tu_parent.user_id
|
||||
ORDER BY
|
||||
daily.date DESC
|
||||
</select>
|
||||
|
||||
<select id="getPurchaseByUserId" parameterType="Integer" resultType="com.ruoyi.domain.entity.TtUserBlendErcash">
|
||||
SELECT * FROM tt_user_blend_ercash WHERE type = 0 AND user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="getCommissionRateByUserId" parameterType="Integer" resultType="BigDecimal">
|
||||
SELECT commission_rate FROM tt_user WHERE user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<update id="updateCommissionRate">
|
||||
UPDATE tt_user SET commission_rate = #{commissionRate} WHERE user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<select id="getCommissionList" parameterType="Integer" resultType="com.ruoyi.domain.entity.TtCommissionRecord">
|
||||
SELECT * FROM tt_commission_record WHERE user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="getLastMonthTotalUserExpenditure" resultType="com.ruoyi.promo.domain.dto.TotalUserExpenditureDTO">
|
||||
SELECT
|
||||
tu.user_id, tu.user_name, tu.user_type, tu.parent_id, tu.commission_rate,
|
||||
SUM(ABS(tube.amount)) AS amount
|
||||
FROM
|
||||
tt_user AS tu
|
||||
LEFT JOIN
|
||||
tt_user_blend_ercash AS tube ON tu.user_id = tube.user_id
|
||||
WHERE
|
||||
tu.user_type = 02
|
||||
AND tube.type = 0
|
||||
AND tube.create_time >= DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
|
||||
AND tube.create_time < DATE_FORMAT(CURDATE(), '%Y-%m-01')
|
||||
GROUP BY
|
||||
tu.user_id
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user