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

    <select id="statisticsRealGoodsData" resultType="com.cyksj.model.entity.RealGoodsData">
        select * from (select goods_id,
        sku_id,
        max(goods_title) as goods_title,
        max(spec_val) as spec_val,
        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
        from real_goods_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,sku_id)s where s.num_of_user > 0 and num_of_order > 0 and money > 0
    </select>

    <select id="statisticsRegisterAccountData" resultType="com.cyksj.model.entity.RegisterAccountData">
        select platform,
        sum(num_of_user) as numOfUser,
        sum(num_of_order) as numOfOrder,
        cast(sum(money)/100 as decimal(20,2)) as money,
        sum(num_of_refund_order) as numOfRefundOrder,
        cast(sum(refund_money)/100 as decimal(20,2)) as refundMoney
        from register_account_data
        <where>
            <if test="startDate != null">
                statistics_date >= #{startDate}
            </if>
            <if test="endDate != null">
                and statistics_date &lt; #{endDate}
            </if>
        </where>
        group by platform
    </select>
</mapper>