<?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="cn.qg.qaplatform.mapper.xyqb.XyqbMapper">

    <!--  审核通过未提现  xyqb库 -->
    <select id="queryAuthAndUnWithdraw" resultType="java.lang.String">
        SELECT afrr.user_id
        FROM apply_funding_risk_record as afrr
        LEFT JOIN assets_order as ao ON afrr.assets_order_id = ao.id
        <where>
            afrr.apply_status = 2
            AND ao.status &lt;&gt; 1
            <if test="channel != null">
                AND ao.created_from = #{channel}
            </if>
            <if test="fundId != null">
                AND afrr.funding_corp_id=#{fundId}
            </if>
        </where>
    </select>

    <!-- 获取不同放款状态的用户Id列表 xyqb库 -->
    <select id="getLoanStatusUserIdList" resultType="java.lang.String">
        SELECT lah.`user_id`
        FROM `loan_application_history` as lah
        LEFT JOIN `apply_funding_risk_record` as afrr
        on lah.`user_id` = afrr.`user_id`
        <where>
            `progress` = #{progress}
            <if test="channel != null">
                AND lah.`created_from` = #{channel}
            </if>
            <if test="fundId != null">
                AND afrr.`funding_corp_id` = #{fundId}
            </if>
        </where>
    </select>

    <!-- 根据用户id获取放款进度 -->
    <select id="getLoanProgressByUserId" resultType="java.lang.Integer">
        SELECT `progress` FROM `loan_application_history`
        WHERE `user_id`=#{userId}
    </select>

</mapper>