CompanyMemberMappingMapper.xml 5.58 KB
<?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.subsidy.mapper.CompanyMemberMappingMapper">

    <select id="companyAuthMembersCount" parameterType="long" resultType="integer">
        SELECT
            count(
            DISTINCT ( t2.id ))
        FROM
            company_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.company_id = #{companyId}
            AND t.member_status = 1
            AND t2.first_login IS NOT NULL
    </select>

    <select id="memberCompany" parameterType="long" resultType="com.subsidy.model.CompanyDictDO">
        SELECT
            t2.*
        FROM
            company_member_mapping t
            LEFT JOIN company_dict t2 ON t.company_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.member_status = 1
            AND t.member_id = #{memberId}
    </select>

    <select id="companyMembers" parameterType="long" resultType="string">
        SELECT
            concat(t2.user_name,t2.telephone,t2.id_card)
        FROM
            company_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.company_id = #{companyId}
            AND t.member_status = 1
    </select>

    <select id="noCompanyMembers" resultType="com.subsidy.model.MemberDO">
        SELECT
            *
        FROM
            member t
        WHERE
            t.delete_date IS NOT NULL
            AND t.id NOT IN (
            SELECT DISTINCT
                ( t2.member_id )
            FROM
                company_member_mapping t2
            WHERE
            t2.delete_date IS NOT NULL
            AND t2.member_status = 1)
            and t.user_name like concat('%',#{userName} ,'%')
            and t.id_card like concat('%',#{idCard} ,'%')
    </select>

    <select id="companyAccountMembers" resultType="com.subsidy.model.MemberDO">
        SELECT
            t2.*
        FROM
            company_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.company_id = #{companyId}
            AND t2.account_name = #{accountName}
            AND t.member_status = 1
    </select>

    <select id="memberCompanys" parameterType="long" resultType="com.subsidy.vo.member.MemberCompanyVO">
        SELECT
            t.company_id,
            t2.company_name,
            t.create_date
        FROM
            company_member_mapping t
            LEFT JOIN company_dict t2 ON t.company_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.member_id =#{memberId}
            order by t.create_date desc,t.id desc
    </select>

    <select id="departMembers" parameterType="long" resultType="com.subsidy.vo.member.DepartMembersVO">
        SELECT
            t2.user_name,
            t2.telephone,
            t2.id_card,
            t2.gender,
            t2.email,
            t2.qq_no,
            t2.wechat,
            t.create_date
        FROM
            company_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.company_id = #{companyId}
            <if test="userName != null and userName !=''">
               and ( t2.user_name like concat('%',#{userName} ,'%')
                or t2.id_card like concat('%',#{userName} ,'%')
                or t2.telephone like concat('%',#{userName} ,'%'))
            </if>
            and t.member_status = 0
            order by t.id desc
    </select>

    <select id="attendMembers" resultType="com.subsidy.vo.member.AttendMembersVO">
        SELECT DISTINCT
            t1.id,
            t1.user_name,
            t1.account_name_en,
            t1.account_name,
            t1.gender,
            t1.telephone,
            t1.id_card,
            t1.email
        FROM
            member t1
            LEFT JOIN company_member_mapping t3 ON t1.id = t3.member_id
            LEFT JOIN class_member_mapping t2 ON t1.id = t2.member_id
            LEFT JOIN member_department_mapping t4 ON t1.id = t4.member_id
        WHERE
            t1.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
            AND t3.member_status = 1
            AND t2.id IS NOT NULL
            AND t3.company_id = #{companyId}
            AND t4.member_status = 1
            AND t4.department_id = #{departmentId}
            <if test="userName != null and userName != ''">
                and ( t1.user_name like concat('%',#{userName} ,'%')
                or t1.id_card like concat('%',#{userName} ,'%')
                or t1.telephone like concat('%',#{userName} ,'%'))
            </if>
    </select>

    <select id="memberAttendInfo" resultType="com.subsidy.vo.member.MemberAttendInfoVO">
        SELECT
            t2.id,
            t2.class_name,
            t.create_date
        FROM
            class_member_mapping t
            LEFT JOIN class_dict t2 ON t.class_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.member_id = #{memberId}
            AND t2.company_id = #{companyId}
        order by t.create_date desc
    </select>

</mapper>