<?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.bonus.canteen.core.menu.mapper.MenuDishesSaleRecordMapper">
    <select id="selectTopDishesIdList" resultType="java.lang.Long">
        select
        dishes_id
        from
        menu_dishes_sale_record
        <where>
            stall_id in
            <foreach collection="stallIdList" item="stallId" open="(" separator="," close=")">
                #{stallId}
            </foreach>
        </where>
        order by
        sale_num desc
    </select>
    <select id="selectMonthSalesStall" resultType="com.bonus.canteen.core.menu.model.MenuStallSaleModel">
        select
        stall_id,
        sum(monthly_sales) as monthly_sales
        from
        menu_dishes_sale_record
        where
        sale_month = month(curdate())
        and stall_id in
        <foreach collection="stallIdList" item="stallId" open="(" separator="," close=")">
            #{stallId}
        </foreach>
        group by
        stall_id
    </select>
</mapper>
