<?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.mcwl.communityCenter.mapper.InviteMapper">

    <select id="selectInviteIds" resultType="java.lang.Long">
        select user_id
        from cc_community_user
        where tenant_id = #{tenantId}
          and community_id = #{communityId}
          and invite_id is not null
          and del_flag = '0'
    </select>
    <select id="isInvite" resultType="com.mcwl.communityCenter.domain.Invite">
        select i.id,
               invite_type,
               fee_type
        from cc_community_user cu
                 left join cc_invite i on cu.invite_id = i.id
        where cu.tenant_id = #{tenantId}
          and cu.community_id = #{communityId}
          and cu.user_id = #{userId}
          and cu.invite_id is not null
          and cu.del_flag = '0'
          and i.del_flag = '0'
    </select>
    <select id="selectByTenantIdAndCommunityIdAndInviteeUserId"
            resultType="com.mcwl.communityCenter.domain.Invite">
        select i.id,
               tenant_id,
               community_id,
               fee_type,
               remark
        from cc_community_user cu
                 left join cc_invite i on cu.invite_id = i.id
        where tenant_id = #{tenantId}
          and community_id = #{communityId}
          and user_id = #{inviteeUserId}
          and cu.invite_id is not null
          and cu.del_flag = '0'
          and i.del_flag = '0'
    </select>
</mapper>