<?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.fjhx.sale.mapper.sample.SampleProductMapper">
    <select id="getPage" resultType="com.fjhx.sale.entity.sample.vo.SampleProductVo">
        SELECT
            t1.id,
            t1.sample_id,
            t1.product_id,
            t2.`code` AS contractCode,
            t2.user_name AS userName,
            t2.version AS contractVersion,
            t1.expend_quantity expendQuantity,
            ( SELECT create_time FROM claim_contract WHERE contract_id = t2.id ORDER BY create_time DESC LIMIT 1 ) AS claimTime
        FROM
            sample_product t1
            LEFT JOIN sample t2 ON t1.sample_id = t2.id
            ${ew.customSqlSegment}
    </select>

</mapper>
