<?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.cyksj.mapper.manage.statistics.StreamingAccountDataMapper">

    <select id="statisticsStreamingData" resultType="com.cyksj.model.entity.StreamingAccountData">
        select goods_id,
               max(account_name) as accountName,
               sum(num_of_user) as num_of_user,
               sum(num_of_order) as num_of_order,
               cast(sum(money)/100 as decimal(20,2)) as money,
               sum(num_of_month_order) as num_of_month_order,
               sum(num_of_season_order) as num_of_season_order,
               sum(num_of_year_order) as num_of_year_order,
               sum(num_of_code_order) as num_of_code_order,
               sum(num_of_distribute_order) as numOfDistributeOrder,
               sum(distribute_order_money) as distributeOrderMoney
        from `streaming_account_data`
        <where>
            <if test="startDate != null">
                statistics_date >= #{startDate}
            </if>
            <if test="endDate != null">
                and statistics_date &lt; #{endDate}
            </if>
        </where>
        group by goods_id
    </select>
</mapper>