alive-admin/alive-server/target/classes/mapper/system/TMemberMapper.xml

221 lines
13 KiB
XML
Raw Normal View History

2024-05-27 16:26:14 +08:00
<?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.system.mapper.TMemberMapper">
<resultMap type="com.ruoyi.system.domain.TMember" id="TMemberResult">
<result property="id" column="id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="account" column="account" />
<result property="accountType" column="account_type" />
<result property="referId" column="refer_id" />
<result property="allPid" column="all_pid" />
<result property="passwordLogin" column="password_login" />
<result property="passwordPay" column="password_pay" />
<result property="shareCode" column="share_code" />
<result property="uid" column="uid" />
<result property="level" column="level" />
<result property="minLevel" column="min_level" />
<result property="shareNum" column="share_num" />
<result property="teamNum" column="team_num" />
<result property="topUser" column="top_user" />
</resultMap>
<sql id="selectTMemberVo">
select id, create_time, update_time, account,top_user, account_type, refer_id, all_pid, password_login, password_pay, share_code, uid, level, min_level, share_num, team_num from t_member
</sql>
<select id="findUserAddressById" parameterType="Integer" resultType="java.lang.String">
select tm1.account from t_member tm LEFT JOIN t_member tm1 ON tm.refer_id=tm1.id WHERE tm.id=#{id}
</select>
<select id="sumBoxNumber" parameterType="Long" resultType="java.lang.Integer">
SELECT IFNULL(SUM(buy_number),0) FROM node WHERE user_id in(
SELECT id FROM t_member WHERE id != #{userId} and all_pid like concat('%,', #{userId}, ',%')
)
</select>
<select id="findTMemberList" parameterType="com.ruoyi.system.domain.TMember" resultMap="TMemberResult">
select tm.*
from t_member tm
<where>
<if test="id != null "> and tm.id = #{id}</if>
<if test="topUser != null "> and tm.top_user = #{topUser}</if>
<if test="account != null and account != ''"> and tm.account = #{account}</if>
<if test="accountType != null "> and tm.account_type = #{accountType}</if>
<if test="referId != null "> and tm.refer_id = #{referId}</if>
<if test="allPid != null and allPid != ''"> and tm.all_pid = #{allPid}</if>
<if test="passwordLogin != null and passwordLogin != ''"> and tm.password_login = #{passwordLogin}</if>
<if test="passwordPay != null and passwordPay != ''"> and tm.password_pay = #{passwordPay}</if>
<if test="shareCode != null and shareCode != ''"> and tm.share_code = #{shareCode}</if>
<if test="uid != null and uid != ''"> and tm.uid = #{uid}</if>
<if test="level != null "> and tm.level = #{level}</if>
<if test="minLevel != null "> and tm.min_level = #{minLevel}</if>
<if test="shareNum != null "> and tm.share_num = #{shareNum}</if>
<if test="teamNum != null "> and tm.team_num = #{teamNum}</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and tm.create_time between #{params.beginTime} and #{params.endTime}</if>
</where>
order by tm.id desc
</select>
<select id="selectTMemberList" parameterType="com.ruoyi.system.domain.TMember" resultMap="TMemberResult">
select tm.*,
(SELECT IFNULL(SUM(op_value),"0") FROM t_member_wallet_log WHERE member_id=tm.id AND op_type=12) as rebate,
(SELECT IFNULL(SUM(op_value),"0") FROM t_member_wallet_log WHERE member_id=tm.id AND op_type in(4,6,8)) as brit,
(SELECT IFNULL(SUM(op_value),"0") FROM t_member_wallet_log WHERE member_id=tm.id AND op_type in(10,11)) as integral,
(SELECT IFNULL(SUM(op_value),"0") FROM t_member_wallet_log WHERE member_id=tm.id AND op_type in(5,7,9)) as accessories
from t_member tm
<where>
<if test="id != null "> and tm.id = #{id}</if>
<if test="topUser != null "> and tm.top_user = #{topUser}</if>
<if test="account != null and account != ''"> and tm.account = #{account}</if>
<if test="accountType != null "> and tm.account_type = #{accountType}</if>
<if test="referId != null "> and tm.refer_id = #{referId}</if>
<if test="allPid != null and allPid != ''"> and tm.all_pid = #{allPid}</if>
<if test="passwordLogin != null and passwordLogin != ''"> and tm.password_login = #{passwordLogin}</if>
<if test="passwordPay != null and passwordPay != ''"> and tm.password_pay = #{passwordPay}</if>
<if test="shareCode != null and shareCode != ''"> and tm.share_code = #{shareCode}</if>
<if test="uid != null and uid != ''"> and tm.uid = #{uid}</if>
<if test="level != null "> and tm.level = #{level}</if>
<if test="minLevel != null "> and tm.min_level = #{minLevel}</if>
<if test="shareNum != null "> and tm.share_num = #{shareNum}</if>
<if test="teamNum != null "> and tm.team_num = #{teamNum}</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and tm.create_time between #{params.beginTime} and #{params.endTime}</if>
</where>
order by tm.id desc
</select>
<select id="findInviteRespList" parameterType="com.ruoyi.system.domain.vo.InviteResp" resultType="com.ruoyi.system.domain.vo.InviteResp">
SELECT tm.id,tm.account account,tm.create_time as createTime,tm2.account as address,
SUM(nbl.buy_count) as buyCount,SUM(nbl.buy_amount) as buyAmount,SUM(nbl.nft_number) as nftNumber,MAX(pay_coin) as payCoin,SUM(contribution) as contribution
FROM t_member tm LEFT JOIN
t_member tm2 ON tm.refer_id=tm2.id LEFT JOIN
(SELECT user_id,buy_count,buy_amount,pay_coin,nft_number,contribution from node_buy_log WHERE status=3) as nbl
ON tm.id = nbl.user_id
GROUP BY tm.id
<where>
<if test="id != null "> and tm.id = #{id}</if>
<if test="account != null and account != ''"> and tm.account = #{account}</if>
<if test="address != null and address != ''"> and tm2.account = #{address}</if>
</where>
order by tm.id desc
</select>
<select id="findUserBoxRespList" resultType="com.ruoyi.system.domain.vo.UserBoxResp">
SELECT tm.refer_id as referId,IFNULL(SUM(buy_number),0) as buyNumber from t_member tm
LEFT JOIN node n ON tm.id=n.user_id WHERE tm.refer_id in
<foreach collection="ids" item="referId" open="(" separator="," close=")">
#{referId}
</foreach>
GROUP BY tm.refer_id
</select>
<select id="findTMember" parameterType="com.ruoyi.system.domain.TMember" resultMap="TMemberResult">
<include refid="selectTMemberVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="topUser != null "> and top_user = #{topUser}</if>
<if test="account != null and account != ''"> and account = #{account}</if>
<if test="accountType != null "> and account_type = #{accountType}</if>
<if test="referId != null "> and refer_id = #{referId}</if>
<if test="allPid != null and allPid != ''"> and all_pid = #{allPid}</if>
<if test="passwordLogin != null and passwordLogin != ''"> and password_login = #{passwordLogin}</if>
<if test="passwordPay != null and passwordPay != ''"> and password_pay = #{passwordPay}</if>
<if test="shareCode != null and shareCode != ''"> and share_code = #{shareCode}</if>
<if test="uid != null and uid != ''"> and uid = #{uid}</if>
<if test="level != null "> and level = #{level}</if>
<if test="minLevel != null "> and min_level = #{minLevel}</if>
<if test="shareNum != null "> and share_num = #{shareNum}</if>
<if test="teamNum != null "> and team_num = #{teamNum}</if>
</where>
limit 1
</select>
<select id="selectTMemberById" parameterType="Integer" resultMap="TMemberResult">
<include refid="selectTMemberVo"/>
where id = #{id}
</select>
<insert id="insertTMember" parameterType="com.ruoyi.system.domain.TMember" useGeneratedKeys="true" keyProperty="id">
insert into t_member
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="account != null and account != ''">account,</if>
<if test="accountType != null">account_type,</if>
<if test="referId != null">refer_id,</if>
<if test="allPid != null and allPid != ''">all_pid,</if>
<if test="passwordLogin != null and passwordLogin != ''">password_login,</if>
<if test="passwordPay != null and passwordPay != ''">password_pay,</if>
<if test="shareCode != null and shareCode != ''">share_code,</if>
<if test="uid != null and uid != ''">uid,</if>
<if test="level != null">level,</if>
<if test="minLevel != null">min_level,</if>
<if test="shareNum != null">share_num,</if>
<if test="teamNum != null">team_num,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="account != null and account != ''">#{account},</if>
<if test="accountType != null">#{accountType},</if>
<if test="referId != null">#{referId},</if>
<if test="allPid != null and allPid != ''">#{allPid},</if>
<if test="passwordLogin != null and passwordLogin != ''">#{passwordLogin},</if>
<if test="passwordPay != null and passwordPay != ''">#{passwordPay},</if>
<if test="shareCode != null and shareCode != ''">#{shareCode},</if>
<if test="uid != null and uid != ''">#{uid},</if>
<if test="level != null">#{level},</if>
<if test="minLevel != null">#{minLevel},</if>
<if test="shareNum != null">#{shareNum},</if>
<if test="teamNum != null">#{teamNum},</if>
</trim>
</insert>
<update id="updateTMember" parameterType="com.ruoyi.system.domain.TMember">
update t_member
<trim prefix="SET" suffixOverrides=",">
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="account != null and account != ''">account = #{account},</if>
<if test="accountType != null">account_type = #{accountType},</if>
<if test="referId != null">refer_id = #{referId},</if>
<if test="allPid != null and allPid != ''">all_pid = #{allPid},</if>
<if test="passwordLogin != null and passwordLogin != ''">password_login = #{passwordLogin},</if>
<if test="passwordPay != null and passwordPay != ''">password_pay = #{passwordPay},</if>
<if test="shareCode != null and shareCode != ''">share_code = #{shareCode},</if>
<if test="uid != null and uid != ''">uid = #{uid},</if>
<if test="level != null">level = #{level},</if>
<if test="minLevel != null">min_level = #{minLevel},</if>
<if test="shareNum != null">share_num = #{shareNum},</if>
<if test="teamNum != null">team_num = #{teamNum},</if>
<if test="topUser != null">top_user = #{topUser},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTMemberByIds" parameterType="String">
delete from t_member where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="countUserByTopUser" resultType="java.lang.Integer">
SELECT (select COUNT(*) from t_member WHERE top_user=1 and id IN
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach> )
+
(SELECT COUNT(*) from t_member WHERE top_user=1 and all_pid LIKE concat('%,', #{id},',%'))
</select>
<select id="getTeamNodeNumber" resultType="java.lang.Integer">
SELECT IFNULL(SUM(buy_count),0) from node_buy_log WHERE user_id in(SELECT id from t_member WHERE all_pid LIKE concat('%,', #{id},',%') and id != #{id}
) and status=3 and order_number != '0x000000000000'
</select>
</mapper>