<?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.modules.investment.mapper.IbaProjectFundMapper">

    <resultMap id="BaseResultMap" type="org.springblade.modules.investment.pojo.entity.IbaProjectFund">
            <id property="id" column="id" />
            <result property="projectId" column="project_id" />
            <result property="year" column="year" />
            <result property="tollInflow" column="toll_inflow" />
            <result property="otherInflow" column="other_inflow" />
            <result property="constructInvestOutflow" column="construct_invest_outflow" />
            <result property="constructProportionOutflow" column="construct_proportion_outflow" />
            <result property="borrowPrincipalOutflow" column="borrow_principal_outflow" />
            <result property="borrowInterestOutflow" column="borrow_interest_outflow" />
            <result property="operateMaintainOutflow" column="operate_maintain_outflow" />
            <result property="operateOverhaulOutflow" column="operate_overhaul_outflow" />
            <result property="operateCapitalOutflow" column="operate_capital_outflow" />
            <result property="operateOperationOutflow" column="operate_operation_outflow" />
            <result property="operateOtherOutflow" column="operate_other_outflow" />
            <result property="operationTaxesOutflow" column="operation_taxes_outflow" />
            <result property="otherOutflow" column="other_outflow" />
            <result property="isDeleted" column="is_deleted" />
            <result property="createTime" column="create_time" />
            <result property="createUser" column="create_user" />
            <result property="updateTime" column="update_time" />
            <result property="updateUser" column="update_user" />
    </resultMap>


    <sql id="Base_Column_List">
        id,project_id,year,toll_inflow,other_inflow,construct_invest_outflow,
        construct_proportion_outflow,borrow_principal_outflow,borrow_interest_outflow,operate_maintain_outflow,operate_overhaul_outflow,
        operate_capital_outflow,operate_operation_outflow,operate_other_outflow,operation_taxes_outflow,other_outflow,
        is_deleted,create_time,create_user,update_time,update_user
    </sql>
    <select id="selectMyList" resultType="org.springblade.modules.investment.pojo.entity.IbaProjectFund">
        select <include refid="Base_Column_List"/>,
            (
                toll_inflow +
                other_inflow
            ) inflowTotal,
            (
                construct_invest_outflow +
                construct_proportion_outflow +
                borrow_principal_outflow +
                borrow_interest_outflow +
                operate_maintain_outflow +
                operate_overhaul_outflow +
                operate_capital_outflow +
                operate_operation_outflow +
                operate_other_outflow +
                operation_taxes_outflow +
                other_outflow
            ) as outflowTotal,
            (
                operate_maintain_outflow+
                operate_overhaul_outflow+
                operate_capital_outflow+
                operate_operation_outflow+
                operate_other_outflow
            ) as costTotal

            from iba_project_fund where project_id = #{projectId}
    </select>
</mapper>
