<?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.purchase.mapper.sales.SalesReturnDetailMapper">
    <select id="getPage" resultType="com.fjhx.purchase.entity.sales.vo.SalesReturnDetailVo">
        SELECT t1.*,
               t2.`code`,
               t2.supply_id,
               IF(r.refund_status IS NULL, 0, r.refund_status) refundStatus
        FROM sales_return_detail t1
                 LEFT JOIN sales_return t2 ON t1.sales_return_id = t2.id
                 LEFT JOIN refund_detail rd ON rd.sales_return_id = t2.id
                 LEFT JOIN refund r ON rd.refund_id = r.id
            ${ew.customSqlSegment}
    </select>

</mapper>
