<?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="org.springblade.finance.mapper.FinanceBillAuditMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="testResultMap" type="org.springblade.finance.entity.FinanceBillAudit">
        <id column="AID" property="aid"/>
        <result column="SID" property="sid"/>
        <result column="AUDITTYPE" property="auditType"/>
        <result column="AUDITSTATUS" property="auditStatus"/>
        <result column="REJECTREASON" property="rejectReason"/>
        <result column="CREATEBYUSERID" property="createByUserId"/>
        <result column="CREATEBYNAME" property="createByName"/>
        <result column="CREATETIME" property="createTime"/>
        <result column="REJECTTIME" property="rejectTime"/>
        <result column="UPLOADTIME" property="uploadTime"/>
        <result column="UPLOADFILENAME" property="uploadFileName"/>
        <result column="UPLOADFILEURI" property="uploadFileUri"/>
        <association property="dateRangeAccount" column="SID" javaType="org.springblade.finance.entity.DateRangeAccount">
        	<id column="SID" property="sid"/>
        	<result column="COMPANY" property="company"/>
        	<result column="CHANNELID" property="channelId"/>
        	<result column="CHANNELNAME" property="channelName"/>
        	<result column="SPID" property="spid"/>
        	<result column="SPNAME" property="spname"/>
        	<result column="SHORTNAME" property="shortname"/>
        	<result column="THEMONTH" property="theMonth"/>
        	<result column="VUSER_PLATFORM" property="onPlatform"/>
        	<result column="VUSER_ONDATERANGE" property="onDateRange"/>
        	<result column="ACCOUNT_USERS" property="accountUsers"/>
        	<result column="MONEY1" property="moneyOne"/>
        	<result column="MONEY1_DISCOUNT" property="moneyOneDiscount"/>
        	<result column="MONEY1_REAL" property="moneyOneReal"/>
        	<result column="MONEY2" property="moneyTwo"/>
            <result column="MONEY1_DISCOUNT_TOTAL" property="moneyOneDiscountTotal"/>
            <result column="MONEY2_DISCOUNT" property="moneyTwoDiscount"/>
        	<result column="MONEY2_DISCOUNT1" property="moneyTwoDiscount1"/>
        	<result column="MONEY2_DISCOUNT2" property="moneyTwoDiscount2"/>
        	<result column="MONEY2_DISCOUNT3" property="moneyTwoDiscount3"/>
        	<result column="MONEY2_DISCOUNT4" property="moneyTwoDiscount4"/>
        	<result column="MONEY2_REAL" property="moneyTwoReal"/>
            <result column="DEAL_ACCOUNT_ID" property="dealAccountId"/>
        </association>
        <collection property="userList" column="AID" ofType="org.springblade.finance.entity.FinanceBillAuditUser">
        	<id column="AUID" property="auid"/>
        	<result column="AID" property="aid"/>
        	<result column="USERID" property="userId"/>
        	<result column="USERNAME" property="userName"/>
        	<result column="CHECKTIME" property="checkTime"/>
        	<result column="CHECKSTATUS" property="checkStatus"/>
        </collection>
    </resultMap>


    <select id="customList" resultMap="testResultMap">
       select * from
		INT_FINANCE_BILL_AUDIT fba
		left join V_INT_ONDATERANGE_ACCOUNT ioa  on fba.SID = ioa.SID
		left join INT_FINANCE_BILL_AUDIT_USER fbau on fba.AID = fbau.AID
		${ew.customSqlSegment}
    </select>

    <select id="customAidList" resultType="java.lang.Long">
        select A.* from (
        select distinct fba.AID from
		INT_FINANCE_BILL_AUDIT fba
		left join V_INT_ONDATERANGE_ACCOUNT ioa  on fba.SID = ioa.SID
		left join INT_FINANCE_BILL_AUDIT_USER fbau on fba.AID = fbau.AID
		${ew.customSqlSegment}
		) A
    </select>

    <select id="customCount" resultType="java.lang.Long">
    	select count(distinct fba.AID) from
		INT_FINANCE_BILL_AUDIT fba
		left join V_INT_ONDATERANGE_ACCOUNT ioa  on fba.SID = ioa.SID
		left join INT_FINANCE_BILL_AUDIT_USER fbau on fba.AID = fbau.AID
		${ew.customSqlSegment}
    </select>

</mapper>
