<?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.m2pool.pool.mapper.PoolMapper">


    <select id="getPoolInfoByCoin" resultType="com.m2pool.pool.dto.PoolInfoDto">
        select
            count(*) poolMc
        from
            ${table}
        where
            `state` ='online'
        group by `date`,`state`
        order by `date` desc limit 1
    </select>

    <select id="get30mPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
        select
            `date`,
            mhs as pv
        from
            ${table}
        where
            `date` >= #{startDate} AND `date` <![CDATA[ <= ]]> #{endDate}
        order by `date`
    </select>

    <select id="getDailyPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto" >
        select
            `date`,
            mhs as pv
        from
            ${table}
        where
            `date` >= #{startDate} AND `date` <![CDATA[ <= ]]> #{endDate}
        order by `date`
    </select>


    <select id="getGRSBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            grs_pool_blkstats
        order by `date` desc
    </select>

    <select id="getMonaBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            mona_pool_blkstats
        order by `date` desc
    </select>

    <select id="getDgbQubitBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgbq_pool_blkstats
        order by `date` desc
    </select>

    <select id="getDgbSkeinBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgbs_pool_blkstats
        order by `date` desc
    </select>

    <select id="getDGBODOBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgbo_pool_blkstats
        order by `date` desc
    </select>

    <select id="getDgbQubitA10BlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgb_qubit_a10_pool_blkstats
        order by `date` desc
    </select>

    <select id="getDgbSkeinA10BlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgb_skein_a10_pool_blkstats
        order by `date` desc
    </select>

    <select id="getDGBODOB20BlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgb_odo_b20_pool_blkstats
        order by `date` desc
    </select>

    <select id="getNEXABlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            nexa_pool_blkstats
        order by `date` desc
    </select>

    <select id="get30mAccountPowerListByAccount" resultType="com.m2pool.pool.dto.PowerLineDto" statementType="STATEMENT">
        select
            `date`,
            `user`,
            mhs pv
        from
            ${table}
        where
            `user` = "${user}"
        order by date desc limit 48
    </select>

    <select id="getDailyAccountPowerListByAccount" resultType="com.m2pool.pool.dto.PowerLineDto" statementType="STATEMENT">
        select
            t.date `date`,
            p.user,
            t.mhs pv
        from
            ${table} p
            join (
                SELECT
                    `date`,
                    `user`,
                    sum(mhs) mhs
                FROM
                    ${table}
                where
                    `user` = "${user}" GROUP BY `date`,`user`) t
            on p.date =t.date
        where
            p.`user` = "${user}"
        group by t.date,p.user
        order by t.date desc limit 30
    </select>

    <select id="getDailyAccountPowerDistributionList" resultType="com.m2pool.pool.dto.MinerDataDto" statementType="STATEMENT">
        select
            m.date,
            m.user `user`,
            m.miner miner,
            m.mhs mhs
        from
            ${table} m
            join(
                SELECT
                    MAX(`date`) AS last_time,
                    user
                FROM
                    ${table}
                where
                    `user` = "${user}"
                GROUP BY `date` ,`user`
                order by  `date` desc limit 1
            ) t
            on m.date = t.last_time
            where  m.date = t.last_time and m.`user` = "${user}"
    </select>

    <select id="getMinerPowerList" resultType="com.m2pool.pool.dto.PowerLineDto" statementType="STATEMENT">
        select
            `date`,
            mhs pv
        from
            ${table} p
        where
            `user` = '${user}'
            and miner = '${miner}'
        order by `date` desc limit 48
    </select>

    <select id="getDailyMinerPowerDistributionList" resultType="com.m2pool.pool.dto.MinerDataDto" statementType="STATEMENT">
        select
            m.date,
            m.user `user`,
            m.miner miner,
            m.mhs24h mhs
        from
            ${table} m
            join(
                SELECT
                    MAX(`date`) AS last_time,
                    user
                FROM
                    ${table}
                where
                    `user` = "${user}"
                    and miner = "${miner}"
                GROUP BY `date` ,`user`
                order by  `date` desc limit 1
            ) t
            on m.date = t.last_time
    </select>


    <select id="getHourMinerDataList" resultType="com.m2pool.pool.dto.MinerDataDto" statementType="STATEMENT">
            select
                `date`,
                `user`,
                miner miner,
                mhs30m mhs,
                `state`,
                last_submit lastSubmit
            from
                ${table}
            where
                `date` = '${now}'
            order by `date`
    </select>

    <select id="getDailyMinerDataList" resultType="com.m2pool.pool.dto.MinerDataDto" statementType="STATEMENT">
        select
            `date`,
            `user`,
            miner,
            mhs24h mhs,
            `state`,
            last_submit lastSubmit
        from
            ${table}
        where
            `date` = '${now}'
        order by `date`
    </select>

    <select id="getLastDataTime" resultType="java.lang.Integer">
        select count(`date`) from ${table} where `date` >= '${date}' order by `date` desc
    </select>

    <select id="getDailyPoolPowerDistributionList" resultType="com.m2pool.pool.dto.MinerDataDto">
        select
            m.date,
            m.user `user`,
            m.miner miner,
            m.mhs24h mhs
        from
            ${table} m
            join(
                SELECT
                    DATE_FORMAT(`date`, '%Y-%m-%d 00:00:00') AS dfdate,
                    MAX(`date`) AS last_time
                FROM
                    ${table}
                GROUP BY `date`
                order by  `date` desc limit 1
            ) t
            on m.date = t.last_time
    </select>

    <select id="getNowPoolPower" resultType="java.lang.Double">
        select sum(mhs30m) from ${table} group by `date`  order by `date` desc limit 1;
    </select>

    <select id="getMinerInfoList" resultType="com.m2pool.pool.dto.MinerDataDto">
        select
            m.`date`,
            m.`user`,
            m.miner,
            m.last_submit lastSubmit,
            m.`state` online,
            m.mhs30m mhs,
            m.mhs24h mhs24h
        from
            ${table}_realv2 m
            left join(
                SELECT
                    MAX(`date`) AS last_time
                FROM
                    ${table}_realv2
                order by  `date` desc limit 1
            ) t
            on m.date = t.last_time
        where
            m.date = t.last_time
    </select>

    <select id="get24hMinerInfoList" resultType="com.m2pool.pool.dto.MinerDataDto">
        select
            m.`date`,
            m.`user`,
            m.miner,
            m.last_submit lastSubmit,
            m.`state` online,
            m.mhs mhs
        from
            ${table} m
            left join(
                SELECT
                    MAX(`date`) AS last_time
                FROM
                    ${table}
                order by  `date` desc limit 1
            ) t
            on m.date = t.last_time
        where
            m.date = t.last_time
    </select>

    <select id="getUserHourMinerDataList" resultType="com.m2pool.pool.dto.MinerDataDto">
        select
            `date`,
            `user`,
            shares1h accepts,
            rejects1h rejects,
            mhs1h mhs,
            mhs24h mhs24h,
            ratio1h rejectsRatio
        from
            ${table} p
        order by `date`
    </select>

    <select id="getUserDailyMinerDataList" resultType="com.m2pool.pool.dto.MinerDataDto">
        select
            `date`,
            `user`,
            shares24h accepts,
            rejects24h rejects,
            mhs1h mhs,
            mhs24h mhs24h,
            ratio24h rejectsRatio
        from
            ${table}
        order by `date`
    </select>

    <select id="getHourPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
        select
            p.date `date`,
            COALESCE(p.value,0) price
        from
            ${table}_price p
        where p.date >= DATE_SUB(NOW(), INTERVAL 35 DAY)
    </select>

    <select id="getHourNetPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
        select
            np.date `date`,
            COALESCE(p.value,0) price,
            COALESCE(np.value,0) pv
        from
            ${table}_price p
            RIGHT join ${table}_net_power np on p.date = np.date
    </select>

    <select id="getNewNEXABlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            nexa_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNowPoolDailyPower" resultType="java.lang.Double">
        select sum(mhs30m) from ${table} group by `date`  order by `date` desc limit 1;
    </select>

    <select id="get24hAccountPowerListByAccount" resultType="com.m2pool.pool.dto.PowerLineDto">
        select
            `date`,
            `user`,
            mhs pv
        from
            ${table}
        where
            `user` = "${user}"
        order by `date`
    </select>

    <select id="getPoolTodayTotalPower" resultType="java.math.BigDecimal">
        select sum(mhs) from ${coin}_pool_30m where `date` &gt; '${date}';
    </select>

    <select id="getUserTodayTotalPower" resultType="com.m2pool.pool.dto.UserPowerDto">
        select user,sum(mhs) mhs from ${coin}_users_30m where date &gt; '${date}' group by `user`
    </select>

    <select id="getDailyPoolPower" resultType="com.m2pool.pool.dto.DateBigDecimalDto">
        select DATE(`date`) as pDate,avg(mhs) `value`  from ${coin}_pool_30m where `date` >= DATE_SUB(NOW(), INTERVAL 90 DAY) group by pDate order by pDate
    </select>

    <select id="getDailyNetPower" resultType="com.m2pool.pool.dto.DateBigDecimalDto">
        select DATE(`date`) as pDate,avg(`value`) `value` from ${coin}_net_power where `date` >= DATE_SUB(NOW(), INTERVAL 90 DAY) group by pDate order by pDate
    </select>

    <select id="getNewGRSBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            grs_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNewMONABlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            mona_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNewDGBQBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
         select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgbq_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNewDGBSBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgbs_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNewDGBOBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            dgbo_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>
    <select id="getAvgNetPower" resultType="java.math.BigDecimal">
        select avg(`value`) from ${coin}_net_power where date &gt; '${date}'
    </select>

    <select id="getNewRXDBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            rxd_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getRXDBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            rxd_pool_blkstats
        order by `date` desc
    </select>
    <select id="getOfflineList" resultType="com.m2pool.pool.dto.OfflineUserMinerDto">
        select
            `date`,
            `user`,
            GROUP_CONCAT(miner SEPARATOR ' | ') miners,
            count(*) offline
        from
            ${table}
        where
            state='offline' and date &gt;= '${date}' group by date,user;
    </select>

    <select id="getALPHBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            alph_pool_blkstats
        order by `date` desc
    </select>

    <select id="getENXBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            enx_pool_blkstats
        order by `date` desc
    </select>

    <select id="getMONEROBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            monero_pool_blkstats
        order by `date` desc
    </select>

    <select id="getXtmBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            sha3x_pool_blkstats
        order by `date` desc
    </select>

    <select id="getNewALPHBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            alph_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNewENXBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            enx_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNewMONEROBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            monero_blkreportprofitv2
        where
         `date` > #{date}
        order by `date`
    </select>

    <select id="getNewXtmBlockInfoList" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select
            height,
            `date`,
            hash,
            reward,
            fees
        from
            sha3x_blkreportprofitv2
        where
            `date` > #{date}
        order by `date`
    </select>



    <insert id="batchInsertMhsDataToDB" statementType="STATEMENT">
        insert into ${table}(
            `date`,
            `user`,
            miner,
            mhs,
            `state`,
            last_submit
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            '${i.date}',
            '${i.user}',
            '${i.miner}',
            ${i.mhs},
            '${i.state}',
            '${i.lastSubmit}'
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertUserMhsDataToDB">
        insert into ${table}(
            `date`,
            `user`,
            mhs,
            mhs24h,
            accepts,
            rejects,
            rejects_ratio
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            '${i.date}',
            '${i.user}',
            ${i.mhs},
            ${i.mhs24h},
            ${i.accepts},
            ${i.rejects},
            ${i.rejectsRatio}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="insertNetPower">
        insert into ${table}(
            `date`,
            `value`
        ) values(
            '${date}',
            ${vo.value}
        )
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="insertPrice">
        insert into ${table}(
            `date`,
            `value`
        ) values(
            '${date}',
            ${vo.value}
        )
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <select id="selectPrice" resultType="java.math.BigDecimal">
        select
            `value`
        from
            ${coin}_price
        order by id desc
        limit 1
    </select>

    <insert id="batchInsertNexaPoolBlkToDB">
        insert into nexa_pool_blkstats (
            `date`,
            height,
            hash,
            reward,
            fees
        ) values
        <foreach collection="list" item="i" separator=",">
        (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
        )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="insertPoolPower">
        insert into ${table}(
            `date`,
            `mhs`,
            `miners`,
            `online`,
            `offline`
        ) values(
            '${vo.dateStr}',
            ${vo.mhs},
            ${vo.miners},
            ${vo.online},
            ${vo.offline}
        )
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertUserMhsDateToDB">
        insert into ${table}(
            `date`,
            `user`,
            `mhs`
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            '${i.date}',
            '${i.user}',
            ${i.mhs}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertGRSPoolBlkToDB">
        insert into grs_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertMONAPoolBlkToDB">
        insert into mona_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertDGBOPoolBlkToDB">
        insert into dgbo_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertDGBQPoolBlkToDB">
        insert into dgbq_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertDGBSPoolBlkToDB">
        insert into dgbs_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertRXDPoolBlkToDB">
        insert into rxd_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertALPHPoolBlkToDB">
        insert into alph_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>
    <insert id="batchInsertENXPoolBlkToDB">
        insert into enx_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="batchInsertMONEROPoolBlkToDB">
        insert into monero_pool_blkstats (
        `date`,
        height,
        hash,
        reward,
        fees
        ) values
        <foreach collection="list" item="i" separator=",">
            (
            #{i.date},
            #{i.height},
            #{i.hash},
            #{i.reward},
            #{i.fees}
            )
        </foreach>
        ON DUPLICATE KEY UPDATE
        `date` = VALUES(`date`)
    </insert>

    <insert id="insertNetBlock">
        insert into ${tableName} (`height`) values(#{height}) ON DUPLICATE KEY UPDATE `height` = VALUES(`height`)
    </insert>
    <insert id="insertDgbTotalHeight">
        insert into dgb_total_block (`height`) values(#{height}) ON DUPLICATE KEY UPDATE `height` = VALUES(`height`)
    </insert>


    <select id="selectNetBlock" resultType="com.m2pool.pool.dto.BlockInfoDto">
        SELECT `date`,height FROM ${tableName} WHERE `date` >= DATE_SUB(now(),INTERVAL 90 DAY) ORDER BY `date` DESC
    </select>
    <select id="selectPoolBlock" resultType="java.lang.Integer">
        SELECT count(*) FROM ${coin}_blkreportprofitv2 WHERE `date` >= #{start} AND date  <![CDATA[ <= ]]>  #{end}
    </select>
    <select id="getAvgPowerForPool" resultType="com.m2pool.pool.dto.DateBigDecimalDto">
        select avg(mhs) `value`  from ${coin}_pool_30m
        where `date` >= #{start} and `date` <![CDATA[ <= ]]>  #{end}
    </select>
    <select id="getAvgPowerForNet" resultType="com.m2pool.pool.dto.DateBigDecimalDto">
        select avg(`value`) `value` from ${coin}_net_power where `date` >= #{start} and `date` <![CDATA[ <= ]]>  #{end}
    </select>
    <select id="getMinerPowerFor30min" resultType="com.m2pool.pool.dto.MinerMhsDto">
        select `date`,`user`,sum(mhs30m) mhs30m from ${coin}_mhsv2 where `date` >= #{startTime} and `date` <![CDATA[ <= ]]>  #{endTime}
        group by `date`,`user`
    </select>
    <select id="getDgbSeriesBlock" resultType="com.m2pool.pool.dto.BlockInfoDto">
        select MAX(height) height from ${tableName};
     </select>
    <select id="getDgbTotalHeight" resultType="java.lang.Integer">
        select height  from dgb_total_block order by `date` DESC LIMIT 1;
    </select>
    <select id="getMoneroBlockInfo" resultType="com.m2pool.pool.entity.BlockInfo">
        select height,difficulty,power,reward,fees,profit from monero_block_info order by id desc limit 1;
    </select>

    <select id="getXtmBlockInfo" resultType="com.m2pool.pool.entity.BlockInfo">
        select height,difficulty,power,reward,fees,profit from sha3x_block_info order by id desc limit 1;
    </select>


    <insert id="insertXtmBlockInfo">
        insert into sha3x_block_info (height,difficulty,power,reward,fees,profit,price)
        values(#{blockInfo.height}
              ,#{blockInfo.difficulty}
              ,#{blockInfo.power}
              ,#{blockInfo.reward}
              ,#{blockInfo.fees}
              ,#{blockInfo.profit}
              ,#{blockInfo.price})
    </insert>


    <delete id="deleteMhs30m">delete from ${coin}_mhs30m where `date` = #{date} </delete>
    <delete id="deletePool30m">delete from ${coin}_pool_30m where `date` = #{date}</delete>
    <delete id="deleteUsers30m">delete from ${coin}_users_30m where `date` = #{date}</delete>


    <select id="getEmailByUsers" resultType="com.m2pool.pool.dto.NoticeMinerCoinListDto">
        select
            `user` email,
            miner_user miner
        from
            user_miner_account
        where
            coin = #{coin} and `miner_user` in
            <foreach collection="list" item="i" separator="," open="(" close=")" index="index">
                #{i.user}
            </foreach>
    </select>
    <select id="getCurrentCoinPrice" resultType="java.math.BigDecimal">
        select `value` from ${table}_price  order by id DESC LIMIT 1;
    </select>


</mapper>


