<?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.mcwl.myInvitation.mapper.InvitationMapper">


    <select id="getTotalAmount" resultType="java.lang.Double">
        select sum(amount)
        from inv_commission
        where user_id = #{userId}
    </select>

    <select id="getEarningsDisplay" resultType="com.mcwl.myInvitation.domain.dto.EarningsDisplay">
        select inv.user_invite_id as userId, count(con.id) as count
        from inv_invitation inv
                 left join inv_consume con
                      on inv.user_invite_id = con.user_id
        where inv.user_id = #{userId}
        group by inv.user_invite_id
    </select>


</mapper>