<?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.supermarket.mapper.SupermarketInfoMapper">

    <select id="pageSupermarket" resultType="com.bonus.canteen.core.supermarket.vo.SupermarketInfoPageVO">
        SELECT
            a.supermarket_id,
            a.supermarket_name,
            a.user_id,
            b.real_name userName,
            a.mobile,
            a.warehouse_id,
            c.warehouse_name,
            a.address,
            a.img_url,
            a.if_print_now,
            a.app_sale_mode,
            a.min_delivery_time,
            a.select_time_interval,
            a.delivery_cost,
            a.auto_verify_day,
            a.delivery_way,
            a.refund_limit_time,
            a.if_relate_drp,
            a.eff_id,
            a.upby,
            a.uptime,
            a.meal_code,
            a.area_id,
            d.area_name,
            a.if_enable_pay_code,
            a.pay_code_url
        FROM
            supermarket_info a
            LEFT JOIN mgr_user b ON a.user_id = b.user_id
            LEFT JOIN drp_warehouse c ON c.warehouse_id = a.warehouse_id
            left join alloc_area d on d.area_id = a.area_id
        <where>
            a.del_flag = #{delFlag}
            <if test="content.supermarketName != null and content.supermarketName != '' ">
                AND a.supermarket_name like #{content.supermarketName}
            </if>
            <if test="content.warehouseId != null">
                AND a.warehouse_id = #{content.warehouseId}
            </if>
            <if test="areaAuth != null and areaAuth.size() > 0">
                and a.area_id in
                <foreach collection="areaAuth" item="areaId" separator="," open="(" close=")">
                    #{areaId}
                </foreach>
            </if>
            <if test="content.areaIdList != null and content.areaIdList.size() > 0">
                AND a.area_id in
                <foreach collection="content.areaIdList" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
    <select id="querySupermarketTree" resultType="com.bonus.canteen.core.supermarket.vo.SupermarketTreeVO">
        select a.supermarket_id,a.supermarket_name from supermarket_info a
        <where>
            <if test="areaAuth != null and areaAuth.size() > 0">
                and a.area_id in
                <foreach collection="areaAuth" item="areaId" separator="," open="(" close=")">
                    #{areaId}
                </foreach>
            </if>
        </where>
    </select>
<!--    <select id="listSupermarketInfo" resultType="net.xnzn.core.supermarket.vo.AppletSupermarketListVO">-->
<!--        SELECT-->
<!--            supermarket_id,-->
<!--            supermarket_name,-->
<!--            mobile,-->
<!--            address,-->
<!--            app_sale_mode,-->
<!--            warehouse_id,-->
<!--            img_url,-->
<!--            eff_id,-->
<!--            crtime,-->
<!--            uptime,-->
<!--            del_flag-->
<!--        FROM-->
<!--            supermarket_info-->
<!--        <where>-->
<!--            <if test="delFlag != null">-->
<!--                AND del_flag = #{delFlag}-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->
<!--    <select id="getConfigById" resultType="net.xnzn.core.supermarket.vo.AppletSupermarketConfigVO">-->
<!--        SELECT-->
<!--            supermarket_id,-->
<!--            min_delivery_time,-->
<!--            select_time_interval,-->
<!--            delivery_cost,-->
<!--            delivery_way,-->
<!--            app_sale_mode,-->
<!--            refund_limit_time,-->
<!--            crtime,-->
<!--            uptime,-->
<!--            area_id-->
<!--        FROM-->
<!--            supermarket_info-->
<!--        WHERE-->
<!--            supermarket_id = #{supermarketId}-->
<!--    </select>-->
    <select id="getRefundLimitTime" resultType="java.lang.Integer">
        SELECT
            refund_limit_time
        FROM
            supermarket_info
        WHERE
            supermarket_id = #{supermarketId}
            AND app_sale_mode = #{appSaleMode}
    </select>
</mapper>
