<?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.ruoyi.web.modules.home.mapper.HomeAppMapper">

    <select id="selectBannersForHome" resultType="com.ruoyi.web.modules.home.vo.HomeBannerVO">
        select banner_id as bannerId,
               banner_image as bannerImage,
               sort_no as sortNo
        from biz_home_banner
        where del_flag = '0'
          and enable_flag = '1'
        order by sort_no asc, create_time asc
        limit #{limit}
    </select>

    <select id="selectPlatformLevel1Nav" resultType="com.ruoyi.web.modules.home.vo.HomeCategoryNavVO">
        select category_id as categoryId,
               category_name as categoryName,
               category_pic as categoryPic,
               sort_no as sortNo
        from biz_goods_category
        where shop_id is null
          and category_level = '1'
          and show_flag = '1'
          and del_flag = '0'
        order by sort_no asc, create_time asc
    </select>

    <select id="selectHotGoodsForHome" resultType="com.ruoyi.web.modules.home.vo.HomeHotGoodsVO">
        select g.goods_id as goodsId,
               g.goods_sn as goodsSn,
               g.goods_name as goodsName,
               g.main_pic as mainPic,
               g.sale_price as salePrice,
               s.shop_id as shopId,
               s.shop_name as shopName
        from biz_goods g
        inner join biz_shop s on g.shop_id = s.shop_id and s.del_flag = '0'
        where g.goods_status = '2'
          and g.del_flag = '0'
          and g.category_id is not null
        order by g.sales_count desc,
                 coalesce(g.audit_time, g.submit_time) desc,
                 g.goods_sn asc
        limit #{limit}
    </select>

</mapper>
