CertMemberMappingMapper.xml 5.9 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.CertMemberMappingMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.CertMemberMappingDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="member_id" property="memberId" />
        <result column="cert_id" property="certId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, member_id, cert_id
    </sql>

    <select id="signManagement" resultType="com.subsidy.vo.cert.SignManagementVO">
        SELECT
        t.id as certId,
        t4.id,
        t4.create_date,
        t.cert_name,
        t.price,
        t6.user_name,
        t5.company_name,
        t4.`status`
        FROM
        cert_dict t
        LEFT JOIN (
        SELECT DISTINCT
        t.id,
        t.cert_id,
        t.member_id,
        t.create_date,
        t.`status`
        FROM
        cert_member_mapping t
        LEFT JOIN cert_type_mapping t3 ON t.cert_id = t3.cert_id
        WHERE
        t.delete_date IS NULL
        AND t3.delete_date IS NULL
        <if test="status != null and status != ''">
            AND t.`status` = #{status}
        </if>
        <if test=" typeId != null and typeId != ''">
            AND t3.type_id = #{typeId}
        </if>
        <if test=" certId != null and certId != ''">
            AND t.cert_id = #{certId}
        </if>
        <if test="startDate != null and start != ''">
            and DATE_FORMAT(t.create_date ,'%Y-%m-%d')>= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
        </if>
        <if test="endDate != null and endDate != ''">
            and DATE_FORMAT(t.create_date ,'%Y-%m-%d')&lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
        </if>
        ) t4 ON t.id = t4.cert_id
        LEFT JOIN member t6 ON t4.member_id = t6.id
        left join company_member_mapping t8 on t8.member_id = t6.id and t8.member_status = 1
        LEFT JOIN company_dict t5 ON t8.company_id = t5.id
        WHERE
        t.delete_date IS NULL
        AND t5.delete_date IS NULL
        AND t6.delete_date IS NULL
        <if test="item != null and item != ''">
            AND (t.cert_name LIKE concat('%',#{item} ,'%')
            AND t5.company_name  LIKE  concat('%',#{item} ,'%'))
        </if>

    </select>

    <select id="getList"  resultType="com.subsidy.vo.cert.GetListVO">
        SELECT
            t.id,
            t2.cert_name,
            t2.id AS cert_id,
            t2.cover_page,
            t.create_date,
            t.status
        FROM
            cert_member_mapping t
            LEFT JOIN cert_dict t2 ON t.cert_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            and t.member_id = #{memberId}
            <if test="status != null and status !=''">
                and t.status = #{status}
            </if>
    </select>

    <select id="getSignInfo" resultType="com.subsidy.vo.cert.GetSignInfoVO">
        SELECT
            t2.user_name,
            t.order_no,
            t.status,
            t3.cert_name
        FROM
            cert_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
            left join cert_dict t3 on t.cert_id = t3.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            and t.cert_id =#{certId}
            and t.member_id = #{memberId}
    </select>

    <select id="memberCertStatus" resultType="integer">
       SELECT
            count( 1 )
        FROM
            cert_member_mapping t
        WHERE
            t.delete_date IS NULL
            AND t.member_id = #{memberId}
            AND t.cert_id = #{certId}
            AND (
                t.`status` = "已报名"
            OR t.`status` = "等待支付"
            OR t.`status` = "有效订单")
    </select>

    <select id="certTypeSignStatus" resultType="com.subsidy.vo.cert.CertSignStatusVO">
        SELECT DISTINCT
            t.id,
            t.cert_name,
            t.cover_page,
            t.price,
            t.scribe_price,
            t4.`status`
        FROM
            cert_dict t
            LEFT JOIN cert_type_mapping t2 ON t.id = t2.cert_id
            LEFT JOIN cert_member_mapping t4 ON t.id = t4.cert_id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t4.delete_date IS NULL
            AND t4.member_id = #{memberId}
            AND t2.type_id = #{typeId}
    </select>

    <select id="certSignInfo" resultType="com.subsidy.vo.cert.CertSignInfoVO">
            SELECT
                t.id,
                t1.user_name,
                t2.company_name,
                t1.telephone,
                t1.id_card,
                t.STATUS,
                t3.price,
                t3.scribe_price,
                t.commit_price
            FROM
                cert_member_mapping t
            LEFT JOIN member t1 ON t.member_id = t1.id
        left join company_member_mapping t5 on t5.member_id = t1.id and t5.member_status = 1
        LEFT JOIN company_dict t2 ON t5.company_id = t2.id
            LEFT JOIN cert_dict t3 ON t.cert_id = t.id
            WHERE
            t.delete_date IS NULL
            AND t1.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            and t.cert_id = #{certId}
            <if test="status != null and status != ''">
                and t.status = #{status}
            </if>
            <if test="userName != null and userName != ''">
                and t1.user_name like concat('%',#{userName} ,'%')
            </if>
    </select>
</mapper>