<?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.YksytFinanceBillAuditMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="testResultMap" type="org.springblade.finance.entity.YksytFinanceBillAudit">
        <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="yksytAccount" column="SID" javaType="org.springblade.finance.entity.YksytAccountView">
            <result column="THEMONTH" property="themonth" />
            <result column="NEWUSER" property="newuser" />
            <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="OLDUSER" property="olduser" />
            <result column="TOTALUSER" property="totaluser" />
            <result column="PRICE" property="price" />
            <result column="MONEY" property="money" />
            <result column="SID" property="sid" />
            <result column="SPID" property="spid" />
            <result column="DEAL_TYPE" property="dealType" />
            <result column="DEAL_ACCOUNT_ID" property="dealAccountId"/>
            <result column="MONEY_DISCOUNT" property="moneyDiscount"/>
            <result column="MONEY_RECKON" property="moneyReckon"/>
        </association>
        <collection property="userList" column="AID" ofType="org.springblade.finance.entity.YksytFinanceBillAuditUser">
            <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"/>
            <result column="PRIORITY" property="priority"/>
        </collection>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        AID, SID, AUDITTYPE, AUDITSTATUS, REJECTREASON, CREATEBYUSERID, CREATEBYNAME, CREATETIME, REJECTTIME, UPLOADTIME, UPLOADFILENAME, UPLOADFILEURI
    </sql>


    <select id="customAidList" resultType="java.lang.Long">
        select A.* from (
        select distinct yfba.AID from
		YKSYT_FINANCE_BILL_AUDIT yfba
		left join V_YKSYT_ACCOUNT ya  on yfba.SID = ya.SID
		left join YKSYT_FINANCE_BILL_AUDIT_USER yfbau on yfba.AID = yfbau.AID
		${ew.customSqlSegment}
		) A
    </select>

    <select id="customCount" resultType="java.lang.Long">
    	select count(distinct yfba.AID) from
		YKSYT_FINANCE_BILL_AUDIT yfba
		left join V_YKSYT_ACCOUNT ya  on yfba.SID = ya.SID
		left join YKSYT_FINANCE_BILL_AUDIT_USER yfbau on yfba.AID = yfbau.AID
		${ew.customSqlSegment}
    </select>

    <select id="customList" resultMap="testResultMap">
        select * from
        YKSYT_FINANCE_BILL_AUDIT yfba
        left join V_YKSYT_ACCOUNT ya  on yfba.SID = ya.SID
        left join YKSYT_FINANCE_BILL_AUDIT_USER yfbau on yfba.AID = yfbau.AID
        ${ew.customSqlSegment}
        ORDER BY yfba.CREATETIME
    </select>

</mapper>
