<?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.kxs.store.biz.mapper.KxsSendTotalMapper">

    <resultMap type="com.kxs.store.api.model.KxsSendTotal" id="KxsSendTotalMap">
        <result column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
        <result column="version" property="version" />
        <result column="total_date" property="totalDate" />
        <result column="total_month" property="totalMonth" />
        <result column="warehouse_id" property="warehouseId" />
        <result column="total_num" property="totalNum" />
        <result column="brand_id" property="brandId" />

    </resultMap>
    <select id="orderMonthTotal" resultType="com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalVO">
        SELECT SUM(total_num) as total_num, total_month as time
        FROM kxs_send_total
        <where>
            and brand_id = #{param.brandId}
            and warehouse_id = #{param.warehouseId}
        </where>
        group by total_month
        order by total_month desc
    </select>
    <select id="orderMonthTotalDetail"
            resultType="com.kxs.store.api.vo.kxsapp.storeOrder.OrderMonthTotalDetailVO">

        SELECT total_num, total_date as time
        FROM kxs_send_total
        <where>
            and brand_id = #{param.brandId}
            and warehouse_id = #{param.warehouseId}
            and total_month = #{param.totalMonth}
        </where>
        order by total_date desc
    </select>

</mapper>
