<?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.ruoyi.dk.mapper.BorrowMapper">
    <select id="pageAdmin" resultType="com.ruoyi.dk.dto.admin.resp.BorrowResp">
        select t1.*,t2.phone_number as customer_login_name,
                ifnull(t3.withdraw_flag,1) as withdraw_flag
        from dk_borrow t1
        left join dk_customer t2 on t1.customer_id = t2.id
        left join dk_borrow_status t3 on t1.borrow_status_id = t3.id
        <where>
            <if test="bo.tradeNo != null and bo.tradeNo != ''">
                and t1.trade_no = #{bo.tradeNo}
            </if>
            <if test="bo.realName != null and bo.realName != ''">
                and (t1.real_name like concat('%',#{bo.realName},'%') or t2.phone_number like concat('%',#{bo.realName},'%'))
            </if>
        </where>
        order by t1.create_time desc
    </select>
</mapper>
