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


    <select id="getMinerAvgPower" resultType="com.m2pool.pool.dto.MinerIncomeDto">
        select `user`,miner,avg(mhs30m) as avgPower from ${coin}_mhsv2
        where `date` >= #{start} and `date` <![CDATA[ <= ]]> #{end}
        group by `user`,miner
    </select>
    <select id="getVaildBlcoks" resultType="java.math.BigDecimal">
        select count(*) from ${coin}_blkreportprofitv2 where state = 1 and `date` >= #{start} and `date` <![CDATA[ <= ]]> #{end}
    </select>


    <insert id="batchInsertHourIncomes">
        INSERT INTO ${coin}_hour_income (user, miner, income, usdt_income)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.user}, #{item.miner}, #{item.income}, #{item.usdtIncome})
        </foreach>
    </insert>
</mapper>


