<?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.xq.mapper.WxTransDataMapper">
    <select id="pageApp" resultType="com.ruoyi.xq.domain.WxTransData">
        select *
        from xq_wx_trans_data t1
        <where>
            <if test="query.status != null">
                and t1.status = #{query.status}
            </if>
            <if test="query.type == 1">
                and t1.sponsor_user_id = #{query.userId}
            </if>
            <if test="query.type == 2">
                and t1.receive_user_id = #{query.userId}
            </if>
            <if test="query.type == 3">
                and (t1.receive_user_id = #{query.userId} or t1.sponsor_user_id = #{query.userId})
            </if>
        </where>
        order by t1.create_time desc
    </select>
    <select id="pageAdmin" resultType="com.ruoyi.xq.dto.admin.account.WxTransDataAdminVo">
        select t1.*,
               t2.nickname as sponsor_nickname,t2.mobile as sponsor_mobile,t2.avatar as sponsor_avatar,
               t3.nickname as receive_nickname,t3.mobile as receive_mobile,t3.avatar as receive_avatar
        from xq_wx_trans_data t1
        left join xq_user t2 on t1.sponsor_user_id = t2.id
        left join xq_user t3 on t1.receive_user_id = t3.id
        <where>
            <if test="bo.sponsorUsercode != null and bo.sponsorUsercode != ''">
                and t1.sponsor_usercode = #{bo.sponsorUsercode}
            </if>
            <if test="bo.sponsorNickname != null and bo.sponsorNickname != ''">
                and t2.nickname like concat('%',#{bo.sponsorNickname},'%')
            </if>
            <if test="bo.sponsorMobile != null and bo.sponsorMobile != ''">
                and t2.mobile = #{bo.sponsorMobile}
            </if>
            <if test="bo.receiveUsercode != null and bo.receiveUsercode != ''">
                and t1.receive_usercode = #{bo.receiveUsercode}
            </if>
            <if test="bo.receiveNickname != null and bo.receiveNickname != ''">
                and t3.nickname like concat('%',#{bo.receiveNickname},'%')
            </if>
            <if test="bo.receiveMobile != null and bo.receiveMobile != ''">
                and t3.mobile = #{bo.receiveMobile}
            </if>
            <if test="bo.status != null ">
                and t1.status = #{bo.status}
            </if>
        </where>
        order by t1.create_time desc
    </select>


</mapper>
