<?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.crm.ib.task.dao.mapper.DailyTradeDao">

    <select id="getData"
            parameterType="com.crm.rely.backend.core.entity.daily.DailyCommonParamEntity"
            resultType="com.crm.rely.backend.core.pojo.table.TradeHistoryTable">
        select trade.*,
        cl.agent_id,agent.sales_id,cl.custom_id,ss.`type` symbol_type
        from trade_history_view_${platform} trade
        left join account_view_${platform} account on trade.login=account.login
        left join custom_login cl on account.login = cl.login
        left join user_info agent on cl.agent_id = agent.id
        left join sys_symbol ss on trade.`symbol` = ss.`code`
        where trade.close_time <![CDATA[>]]> #{stamp}
        order by trade.close_time asc
    </select>

    <select id="findAllTradeBetweenDate" resultType="com.crm.rely.backend.core.pojo.table.TradeHistoryTable">
        select trade.*,
        cl.agent_id,agent.sales_id,cl.custom_id,ss.`type` symbol_type
        from trade_history_view_${platform} trade
        left join account_view_${platform} account on trade.login=account.login
        left join custom_login cl on account.login = cl.login
        left join user_info agent on cl.agent_id = agent.id
        left join sys_symbol ss on trade.`symbol` = ss.`code`
        where trade.close_time <![CDATA[>=]]> #{startDate} and trade.close_time <![CDATA[<]]> #{endDate}
        order by trade.close_time asc
    </select>

    <select id="findAllMissTradeBetweenDate" resultType="com.crm.rely.backend.core.pojo.table.TradeHistoryTable">
        select trade.*,
               cl.agent_id,agent.sales_id,cl.custom_id,ss.`type` symbol_type
        from trade_history_view_${platform} trade
         left join account_view_${platform} account on trade.login=account.login
         left join custom_login cl on account.login = cl.login
         left join user_info agent on cl.agent_id = agent.id
         left join sys_symbol ss on trade.`symbol` = ss.`code`
         left join trade_history_${platform} th on trade.`order` = th.`order`
        where trade.close_time <![CDATA[>=]]> #{startDate} and trade.close_time <![CDATA[<]]> #{endDate} and th.id is null
        order by trade.close_time asc
    </select>

</mapper>