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

    <select id="getDistributionByMinerAccount" resultType="com.m2pool.pool.dto.ProfitDto">
        select
            id,
            create_date `date`,
            amount  profit,
            `state` status
        from
            wallet_in
        where
            `user`=#{ma} and coin =#{coin}
        order by `date` desc
    </select>

    <select id="getOutcomeListByCoinAndUser" resultType="com.m2pool.pool.dto.OutcomeDto">
        select
            `date`,
            coin,
            address,
            amount,
            tx_id txid
        from
            wallet_outv2
        where
            coin= #{coin}
            and `user` = #{ma}
            order by `date` desc
    </select>

    <select id="getDayDistributionByMinerAccount" resultType="com.m2pool.pool.dto.ProfitDto">
        select
            create_date `date`,
            amount profit,
            `state` status
        from
            wallet_in
        where
            `user`= #{ma}
            and coin=#{coin}
        order by create_date desc
    </select>

    <select id="getDayPendingByMinerAccount" resultType="com.m2pool.pool.dto.ProfitDto">
        select
            create_date `date`,
            amount profit,
            `state` status
        from
            wallet_in
        where
            `user`= #{ma}
            and coin=#{coin}
            and `state`= 0
        order by create_date desc
    </select>

    <select id="getTotalOutByCoinAndUser" resultType="java.math.BigDecimal">
        select sum(amount) from wallet_outv2 where coin=#{coin} and `user`=#{ma} group by coin,`user`
    </select>
</mapper>


