<?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.daqing.financial.guarantee.mapper.DgApplyAmountInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.daqing.framework.domain.guarantee.DgApplyAmountInfo">
        <id column="id" property="id" />
        <result column="company_id" property="companyId" />
        <result column="presenter_id" property="presenterId" />
        <result column="apply_amount" property="applyAmount" />
        <result column="apply_time" property="applyTime" />
        <result column="bank" property="bank" />
        <result column="amount_wide" property="amountWide" />
        <result column="en_guarantee_measures" property="enGuaranteeMeasures" />
        <result column="description" property="description" />
        <result column="business_type" property="businessType" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="operating_status" property="operatingStatus" />
        <result column="role_id" property="roleId" />
        <result column="type" property="type" />
    </resultMap>
    <select id="pageByCondition" resultType="com.daqing.financial.guarantee.model.response.BusinessApplicationListResponse">
        select ai.id,ai.company_id,ai.presenter_id,ai.business_code,ai.business_type,ai.apply_amount,ai.apply_time,ai.create_time,
        ai.status,cc.name,cc.phone
        from dg_apply_amount_info ai
        left join crms_company_customer ccl on ai.company_id = ccl.id
        left join crms_customer cc on cc.id = ccl.customer_id
        <where>
            <if test="CustomerNumberOrName != null and CustomerNumberOrName != ''">
                AND ai.business_code LIKE CONCAT('%',#{CustomerNumberOrName},'%') OR cc.name LIKE CONCAT('%',#{CustomerNumberOrName},'%')
            </if>
        </where>
    </select>

    <select id="excelList" resultType="com.daqing.financial.guarantee.model.response.BusinessApplicationListResponse">
        select ai.id,ai.company_id,ai.presenter_id,ai.business_code,ai.business_type,ai.apply_amount,ai.apply_time,ai.create_time,
        ai.status,cc.name,cc.phone
        from dg_apply_amount_info ai
        left join crms_company_customer ccl on ai.company_id = ccl.id
        left join crms_customer cc on cc.id = ccl.customer_id
    </select>

    <select id="selectApplyAmountInfoById" resultType="com.daqing.financial.guarantee.model.response.DgApplyAmountInfoResponse">
        select * from dg_apply_amount_info where id=#{id}
    </select>

</mapper>