<?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="org.jeecg.modules.system.app.mapper.AppContractSignMapper">

    <select id="queryUserSignContractList" resultType="org.jeecg.modules.system.app.vo.ContractSignVO">
        SELECT
        a.id,
        o.product_name,
        c.full_name,
        c.phone,
        a.create_time,
        a.sign_time,
        a.is_sign
        FROM nm_contract_sign a
        LEFT JOIN nm_family_members c ON a.family_id = c.id
        LEFT JOIN nm_contract_info b ON a.org_code = b.org_code
        LEFT JOIN (
        SELECT order_id, MAX(product_name) AS product_name
        FROM nm_order_pro_info
        GROUP BY order_id
        ) o ON a.order_id = o.order_id
        <where>
            <if test="contractName != null and contractName != ''">
                AND b.contract_name LIKE CONCAT('%', #{contractName}, '%')
            </if>
        </where>
    </select>


</mapper>