<?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.SupermarketProductMapper">
<!--    <insert id="saveBatchProduct">-->
<!--        insert into supermarket_product-->
<!--        (supermarket_detail_id,supermarket_id,material_id,putaway_state,if_online,sale_price,pref_price,person_limit,one_day_limit,img_url,inventory_num,crby,upby)-->
<!--        values-->
<!--        <foreach collection="supermarketProductList" item="product" separator=",">-->
<!--            (#{product.supermarketDetailId},-->
<!--            #{product.supermarketId},-->
<!--            #{product.materialId},-->
<!--            #{product.putawayState},-->
<!--            #{product.ifOnline},-->
<!--            #{product.salePrice},-->
<!--            #{product.prefPrice},-->
<!--            #{product.personLimit},-->
<!--            #{product.oneDayLimit},-->
<!--            #{product.imgUrl},-->
<!--            ifnull(#{product.inventoryNum},9999.000),-->
<!--            #{username},-->
<!--            #{username})-->
<!--        </foreach>-->
<!--    </insert>-->
    <update id="minusInventoryByDetailId">
        UPDATE supermarket_product
        SET inventory_num = inventory_num - #{saleNum}
        WHERE
            supermarket_id = #{supermarketId}
            AND supermarket_detail_id = #{detailId}
    </update>
    <update id="plusInventoryByDetailId">
        UPDATE supermarket_product
        SET inventory_num = inventory_num + #{operateNum}
        WHERE
            supermarket_detail_id = #{detailId}
    </update>

<!--    <select id="pageProductRelate" resultType="net.xnzn.core.supermarket.vo.SupermarketProductPageVO">-->
<!--        SELECT-->
<!--        a.supermarket_detail_id,-->
<!--        a.supermarket_id,-->
<!--        d.supermarket_name,-->
<!--        b.material_id,-->
<!--        b.material_name,-->
<!--        b.unit_id,-->
<!--        c.unit_name,-->
<!--        b.bar_code,-->
<!--        a.putaway_state,-->
<!--        a.if_online,-->
<!--        a.sale_price,-->
<!--        a.pref_price,-->
<!--        a.person_limit,-->
<!--        a.one_day_limit,-->
<!--        a.img_url,-->
<!--        <if test="ifRelateDrp == 1">-->
<!--            e.material_num inventoryNum,-->
<!--        </if>-->
<!--        <if test="ifRelateDrp == 2">-->
<!--            a.inventory_num,-->
<!--        </if>-->
<!--        a.upby,-->
<!--        a.uptime,-->
<!--        b.unit_price as buyingPrice,-->
<!--        mmc.category_name-->
<!--        FROM-->
<!--        supermarket_product a-->
<!--        LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--        LEFT JOIN menu_material_category mmc on b.category_id = mmc.category_id-->
<!--        LEFT JOIN drp_unit c ON c.unit_id = b.unit_id-->
<!--        LEFT JOIN supermarket_info d ON a.supermarket_id = d.supermarket_id-->
<!--        <if test="ifRelateDrp == 1">-->
<!--            LEFT JOIN drp_inventory e ON d.warehouse_id = e.warehouse_id and e.material_id = b.material_id and e.unit_id =-->
<!--            b.unit_id-->
<!--        </if>-->
<!--        <where>-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            <if test="content.barCode != null and content.barCode != ''">-->
<!--                AND b.bar_code = #{content.barCode}-->
<!--            </if>-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                AND b.material_name like #{content.materialName}-->
<!--            </if>-->
<!--            <if test="content.putawayState != null">-->
<!--                AND a.putaway_state = #{content.putawayState}-->
<!--            </if>-->
<!--            <if test="content.categoryIdList != null and content.categoryIdList.size() > 0">-->
<!--                and b.category_id in-->
<!--                <foreach close=")" collection="content.categoryIdList" item="categoryId" open="(" separator=",">-->
<!--                    #{categoryId}-->
<!--                </foreach>-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->

<!--    <select id="pageProductNoRelate" resultType="net.xnzn.core.supermarket.vo.SupermarketProductPageVO">-->
<!--        SELECT-->
<!--        a.supermarket_detail_id,-->
<!--        a.supermarket_id,-->
<!--        d.supermarket_name,-->
<!--        b.material_id,-->
<!--        b.material_name,-->
<!--        b.unit_id,-->
<!--        c.unit_name,-->
<!--        b.bar_code,-->
<!--        a.putaway_state,-->
<!--        a.if_online,-->
<!--        a.sale_price,-->
<!--        a.pref_price,-->
<!--        a.person_limit,-->
<!--        a.one_day_limit,-->
<!--        a.img_url,-->
<!--        a.inventory_num,-->
<!--        a.upby,-->
<!--        a.uptime,-->
<!--        mmc.category_name-->
<!--        FROM-->
<!--        supermarket_product a-->
<!--        LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--        LEFT JOIN drp_unit c ON c.unit_id = b.unit_id-->
<!--        LEFT JOIN supermarket_info d ON d.supermarket_id = a.supermarket_id-->
<!--        LEFT JOIN menu_material_category mmc on b.category_id = mmc.category_id-->
<!--        <where>-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            <if test="content.barCode != null and content.barCode != ''">-->
<!--                AND b.bar_code = #{content.barCode}-->
<!--            </if>-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                AND b.material_name like #{content.materialName}-->
<!--            </if>-->
<!--            <if test="content.putawayState != null">-->
<!--                AND a.putaway_state = #{content.putawayState}-->
<!--            </if>-->
<!--            <if test="content.categoryIdList != null and content.categoryIdList.size() > 0">-->
<!--                and b.category_id in-->
<!--                <foreach collection="content.categoryIdList" item="categoryId" separator="," open="(" close=")" >-->
<!--                    #{categoryId}-->
<!--                </foreach>-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->
<!--    <select id="listUnAddProduct" resultType="net.xnzn.core.supermarket.vo.SupermarketUnAddProductListVO">-->
<!--        SELECT-->
<!--        CONCAT( a.material_name, '/', c.unit_name ) showMaterial,-->
<!--        a.material_id,-->
<!--        a.material_name,-->
<!--        a.unit_id,-->
<!--        c.unit_name,-->
<!--        a.bar_code,-->
<!--        a.sale_price,-->
<!--        a.sale_price prefPrice,-->
<!--        a.image_url-->
<!--        FROM-->
<!--        menu_material a-->
<!--        LEFT JOIN supermarket_product b ON a.material_id = b.material_id AND b.supermarket_id = #{content.supermarketId}-->
<!--        LEFT JOIN drp_unit c on c.unit_id = a.unit_id-->
<!--        <where>-->
<!--            b.supermarket_detail_id is null-->
<!--            AND a.material_type = #{materialType}-->
<!--            AND a.del_flag = #{delFlag}-->
<!--            AND (a.area_id = #{content.areaId} or a.area_id is null)-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                AND a.material_name like #{content.materialName}-->
<!--            </if>-->
<!--            <if test="content.barCode != null and content.barCode != ''">-->
<!--                AND a.bar_code like #{content.barCode}-->
<!--            </if>-->
<!--            <if test="content.categoryIdList != null and content.categoryIdList.size() > 0">-->
<!--                AND a.category_id in-->
<!--                <foreach collection="content.categoryIdList" item="categoryId" separator="," open="(" close=")">-->
<!--                    #{categoryId}-->
<!--                </foreach>-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->
<!--    <select id="pageSupermarketProductRelateDrp"-->
<!--            resultType="net.xnzn.core.supermarket.vo.AndroidSupermarketProductPageVO">-->
<!--        SELECT-->
<!--        a.supermarket_detail_id,-->
<!--        a.material_id,-->
<!--        b.material_name,-->
<!--        b.unit_id,-->
<!--        c.unit_name,-->
<!--        a.sale_price,-->
<!--        a.pref_price,-->
<!--        a.inventory_num,-->
<!--        b.bar_code,-->
<!--        b.image_url imgUrl,-->
<!--        b.sales_mode-->
<!--        FROM-->
<!--        supermarket_product a-->
<!--        LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--        LEFT JOIN drp_unit c ON c.unit_id = b.unit_id-->
<!--        <where>-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            AND a.putaway_state = #{putawayState}-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                and ((-->
<!--                b.material_name like concat(concat('%', #{content.materialName}), '%')-->
<!--                or b.pinyin_initials like concat(concat('%', #{pinyinInitials}), '%')-->
<!--                or b.pinyin_full like concat(concat('%', #{pinyinFull}), '%')-->
<!--                )-->
<!--                or b.bar_code = #{content.materialName})-->
<!--            </if>-->
<!--            <if test="content.categoryId != null">-->
<!--                and b.category_id = #{content.categoryId}-->
<!--            </if>-->
<!--                and b. sales_mode = #{putawayState}-->
<!--        </where>-->
<!--    </select>-->
<!--    <select id="getProductByBarCode" resultType="net.xnzn.core.supermarket.vo.AndroidSupermarketProductPageVO">-->
<!--        SELECT-->
<!--            a.supermarket_detail_id,-->
<!--            a.material_id,-->
<!--            b.material_name,-->
<!--            b.unit_id,-->
<!--            c.unit_name,-->
<!--            a.sale_price,-->
<!--            a.pref_price,-->
<!--            a.inventory_num,-->
<!--            b.bar_code,-->
<!--            b.image_url imgUrl,-->
<!--            b.sales_mode-->
<!--        FROM-->
<!--            supermarket_product a-->
<!--            LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--            LEFT JOIN drp_unit c ON c.unit_id = b.unit_id-->
<!--        WHERE-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            AND a.putaway_state = #{putawayState}-->
<!--            AND b.bar_code = #{content.barCode}-->
<!--            AND b.sales_mode = #{putawayState}-->
<!--    </select>-->
<!--    <select id="pageInventoryMaterial"-->
<!--            resultType="net.xnzn.core.supermarket.vo.SupermarketInventoryMaterialPageVO">-->
<!--        SELECT-->
<!--        a.material_id,-->
<!--        c.material_name,-->
<!--        c.category_id,-->
<!--        f.category_name,-->
<!--        c.unit_id,-->
<!--        d.unit_name,-->
<!--        c.bar_code,-->
<!--        IF-->
<!--        (-->
<!--        IF-->
<!--        ( b.if_relate_drp = 1, e.material_num, a.inventory_num ) IS NULL,-->
<!--        0,-->
<!--        IF-->
<!--        ( b.if_relate_drp = 1, e.material_num, a.inventory_num )) inventoryNum-->
<!--        FROM-->
<!--        supermarket_product a-->
<!--        LEFT JOIN supermarket_info b ON b.supermarket_id = a.supermarket_id-->
<!--        LEFT JOIN menu_material c ON c.material_id = a.material_id-->
<!--        LEFT JOIN drp_unit d ON d.unit_id = c.unit_id-->
<!--        LEFT JOIN drp_inventory e ON e.warehouse_id = b.warehouse_id-->
<!--        AND e.material_id = a.material_id-->
<!--        AND c.unit_id = e.unit_id-->
<!--        LEFT JOIN menu_material_category f ON f.category_id = c.category_id-->
<!--        <where>-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                and c.material_name like #{content.materialName}-->
<!--            </if>-->
<!--            <if test="content.barCode != null and content.barCode != ''">-->
<!--                and c.bar_code = #{content.barCode}-->
<!--            </if>-->
<!--            <if test="content.lessNum != null">-->
<!--                and IF( b.if_relate_drp = 1, e.material_num, a.inventory_num ) <![CDATA[ <= ]]> #{content.lessNum}-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->
<!--    <select id="listProductCategory" resultType="net.xnzn.core.supermarket.vo.AppletSupermarketProductListVO">-->
<!--        SELECT DISTINCT-->
<!--            b.category_id,-->
<!--            c.category_name-->
<!--        FROM-->
<!--            supermarket_product a-->
<!--            LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--            LEFT JOIN menu_material_category c ON c.category_id = b.category_id-->
<!--        WHERE-->
<!--            a.supermarket_id = #{supermarketId}-->
<!--            AND a.putaway_state = #{putawayState}-->
<!--            AND a.if_online = #{ifOnline}-->
<!--            AND b.sales_mode = #{putawayState}-->
<!--    </select>-->
<!--    <select id="listProductByCategoryId"-->
<!--            resultType="net.xnzn.core.supermarket.vo.AppletSupermarketProductDetailListVO">-->
<!--        SELECT-->
<!--            a.supermarket_detail_id,-->
<!--            a.material_id,-->
<!--            b.material_name,-->
<!--            b.unit_id,-->
<!--            c.unit_name,-->
<!--            a.sale_price,-->
<!--            a.pref_price,-->
<!--            b.bar_code,-->
<!--            a.inventory_num,-->
<!--            b.image_url imgUrl,-->
<!--            a.person_limit,-->
<!--            b.synopsis-->
<!--        FROM-->
<!--            supermarket_product a-->
<!--            LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--            LEFT JOIN drp_unit c ON c.unit_id = b.unit_id-->
<!--        WHERE-->
<!--            a.supermarket_id = #{supermarketId}-->
<!--            AND b.category_id = #{categoryId}-->
<!--            AND a.putaway_state = #{putawayState}-->
<!--            AND a.if_online = #{ifOnline}-->
<!--            AND b.sales_mode = #{putawayState}-->
<!--    </select>-->
    <select id="listGoodsBuyLimit" resultType="com.bonus.canteen.core.supermarket.po.GoodsBuyLimitModel">
        SELECT
            material_id,
            person_limit,
            one_day_limit
        FROM
            supermarket_product
        WHERE
            supermarket_id = #{supermarketId}
            <if test="putawayState != null">
                AND putaway_state = #{putawayState}
            </if>
            <if test="goodsList != null and goodsList != ''">
                AND material_id in
                <foreach collection="goodsList" item="goods" open="(" close=")" separator=",">
                    #{goods}
                </foreach>
            </if>
    </select>
<!--    <select id="pageWeighProduct" resultType="net.xnzn.core.supermarket.vo.AndroidWeighProductPageVO">-->
<!--        SELECT-->
<!--            a.supermarket_detail_id,-->
<!--            a.material_id,-->
<!--            b.material_name,-->
<!--            b.unit_id,-->
<!--            c.unit_name,-->
<!--            a.sale_price,-->
<!--            a.pref_price,-->
<!--            a.inventory_num,-->
<!--            b.image_url imgUrl-->
<!--        FROM-->
<!--            supermarket_product a-->
<!--            LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--            LEFT JOIN drp_unit c ON c.unit_id = b.unit_id-->
<!--        WHERE-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            and b.sales_mode = #{weightType}-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                and b.material_name like #{content.materialName}-->
<!--            </if>-->
<!--    </select>-->

<!--    <select id="listProductPushInfo" resultType="net.xnzn.core.supermarket.vo.OpenSupermarketProductPushInfoVO">-->
<!--        SELECT A.supermarket_detail_id,-->
<!--               A.supermarket_id,-->
<!--               B.supermarket_name,-->
<!--               C.category_id,-->
<!--               D.category_name,-->
<!--               A.material_id,-->
<!--               C.material_name,-->
<!--               E.unit_id,-->
<!--               E.unit_name,-->
<!--               A.sale_price,-->
<!--               A.pref_price,-->
<!--               A.inventory_num,-->
<!--               C.bar_code,-->
<!--               C.material_code,-->
<!--               A.img_url,-->
<!--               A.person_limit,-->
<!--               A.one_day_limit,-->
<!--               A.putaway_state,-->
<!--               A.if_online,-->
<!--               A.crtime,-->
<!--               A.uptime-->
<!--        FROM supermarket_product A-->
<!--                 LEFT JOIN supermarket_info B ON A.supermarket_id = B.supermarket_id-->
<!--                 LEFT JOIN menu_material C ON A.material_id = C.material_id-->
<!--                 LEFT JOIN menu_material_category D ON C.category_id = D.category_id-->
<!--                 LEFT JOIN drp_unit E ON C.unit_id = E.unit_id-->

<!--    </select>-->
<!--    <select id="checkIfUseInSupermarket" resultType="java.lang.Integer">-->
<!--        SELECT-->
<!--        count(*)-->
<!--        FROM-->
<!--        supermarket_product a-->
<!--        LEFT JOIN supermarket_info b ON a.supermarket_id = b.supermarket_id-->
<!--        WHERE-->
<!--        b.del_flag = 2-->
<!--        and a.material_id in-->
<!--        <foreach collection="materialIdList" item="materialId" separator="," open="(" close=")">-->
<!--            #{materialId}-->
<!--        </foreach>-->
<!--    </select>-->
    <select id="getProductById" resultType="com.bonus.canteen.core.supermarket.vo.SupermarketQueryProductInfoVO">
        SELECT
            a.material_id,
            b.material_name,
            b.image_url imgUrl,
            a.sale_price,
            a.pref_price,
            b.unit_id,
            c.unit_name,
            b.sales_mode
        FROM
            supermarket_product a
            LEFT JOIN menu_material b ON a.material_id = b.material_id
            LEFT JOIN drp_unit c ON c.unit_id = b.unit_id
        WHERE
            a.material_id = #{content.goodsId}
            AND a.supermarket_detail_id = #{content.detailId}
    </select>
<!--    <select id="getPriceByMaterialIds" resultType="net.xnzn.core.supermarket.vo.PriceByMaterialIdVO">-->
<!--        SELECT-->
<!--        did.material_id,-->
<!--        did.unit_price,-->
<!--        did.supplier_id,-->
<!--        ds.supplier_name-->
<!--        FROM-->
<!--        drp_into_detail did-->
<!--        INNER JOIN (-->
<!--        SELECT-->
<!--        did2.material_id,-->
<!--        MAX(dii2.into_date) AS max_into_date-->
<!--        FROM-->
<!--        drp_into_detail did2-->
<!--        INNER JOIN drp_into_inventory dii2 ON did2.into_id = dii2.into_id-->
<!--        <if test="warehouseId != null and warehouseId != '' ">-->
<!--            and dii2.warehouse_id = #{warehouseId}-->
<!--        </if>-->
<!--        WHERE-->
<!--        dii2.del_flag = 2 AND-->
<!--        dii2.status = 2-->
<!--        GROUP BY-->
<!--        did2.material_id-->
<!--        ) AS did_max ON did.material_id = did_max.material_id-->
<!--        INNER JOIN drp_into_inventory dii ON did.into_id = dii.into_id AND dii.into_date = did_max.max_into_date-->
<!--        <if test="warehouseId != null and warehouseId != '' ">-->
<!--            and dii.warehouse_id = #{warehouseId}-->
<!--        </if>-->
<!--        left join drp_supplier ds on did.supplier_id = ds.supplier_id-->
<!--        WHERE-->
<!--        dii.del_flag = 2 AND-->
<!--        dii.status = 2-->

<!--        <if test="materialIds != null and materialIds.size() > 0">-->
<!--            and did.material_id in-->
<!--            <foreach collection="materialIds" item="materialId" separator="," open="(" close=")">-->
<!--                #{materialId}-->
<!--            </foreach>-->
<!--        </if>-->

<!--    </select>-->
<!--    <select id="pageSupermarketProductRelateDrpV4"-->
<!--            resultType="net.xnzn.core.device.android.supermarket.vo.AndroidSupermarketProductPageVO">-->
<!--        SELECT-->
<!--        a.supermarket_detail_id,-->
<!--        a.material_id,-->
<!--        b.material_name,-->
<!--        b.unit_id,-->
<!--        c.unit_name,-->
<!--        a.sale_price,-->
<!--        a.pref_price,-->
<!--        a.inventory_num,-->
<!--        b.bar_code,-->
<!--        b.image_url imgUrl,-->
<!--        b.sales_mode-->
<!--        FROM-->
<!--        supermarket_product a-->
<!--        LEFT JOIN menu_material b ON a.material_id = b.material_id-->
<!--        LEFT JOIN drp_unit c ON c.unit_id = b.unit_id-->
<!--        <where>-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            AND a.putaway_state = #{putawayState}-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                and ((-->
<!--                b.material_name like concat(concat('%', #{content.materialName}), '%')-->
<!--                or b.pinyin_initials like concat(concat('%', #{pinyinInitials}), '%')-->
<!--                or b.pinyin_full like concat(concat('%', #{pinyinFull}), '%')-->
<!--                )-->
<!--                or b.bar_code = #{content.materialName})-->
<!--            </if>-->
<!--            <if test="content.categoryId != null">-->
<!--                and b.category_id = #{content.categoryId}-->
<!--            </if>-->
<!--            and b. sales_mode = #{putawayState}-->
<!--        </where>-->
<!--    </select>-->
<!--    <select id="pageInventoryMaterialV4"-->
<!--            resultType="net.xnzn.core.device.android.supermarket.vo.SupermarketInventoryMaterialPageVO">-->
<!--        SELECT-->
<!--        a.material_id,-->
<!--        c.material_name,-->
<!--        c.category_id,-->
<!--        f.category_name,-->
<!--        c.unit_id,-->
<!--        d.unit_name,-->
<!--        c.bar_code,-->
<!--        IF-->
<!--        (-->
<!--        IF-->
<!--        ( b.if_relate_drp = 1, e.material_num, a.inventory_num ) IS NULL,-->
<!--        0,-->
<!--        IF-->
<!--        ( b.if_relate_drp = 1, e.material_num, a.inventory_num )) inventoryNum-->
<!--        FROM-->
<!--        supermarket_product a-->
<!--        LEFT JOIN supermarket_info b ON b.supermarket_id = a.supermarket_id-->
<!--        LEFT JOIN menu_material c ON c.material_id = a.material_id-->
<!--        LEFT JOIN drp_unit d ON d.unit_id = c.unit_id-->
<!--        LEFT JOIN drp_inventory e ON e.warehouse_id = b.warehouse_id-->
<!--        AND e.material_id = a.material_id-->
<!--        AND c.unit_id = e.unit_id-->
<!--        LEFT JOIN menu_material_category f ON f.category_id = c.category_id-->
<!--        <where>-->
<!--            a.supermarket_id = #{content.supermarketId}-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                and c.material_name like #{content.materialName}-->
<!--            </if>-->
<!--            <if test="content.barCode != null and content.barCode != ''">-->
<!--                and c.bar_code = #{content.barCode}-->
<!--            </if>-->
<!--            <if test="content.lessNum != null">-->
<!--                and IF( b.if_relate_drp = 1, e.material_num, a.inventory_num ) <![CDATA[ <= ]]> #{content.lessNum}-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->
    <select id="listNotRemovedProduct"
            resultType="com.bonus.canteen.core.supermarket.vo.SupermarketNotRemovedProductListVO">
        SELECT
            a.supermarket_detail_id,
            a.material_id,
            b.material_name,
            b.unit_id,
            c.unit_name,
            a.sale_price,
            a.pref_price,
            b.sales_mode,
            a.putaway_state,
            a.if_online,
            <if test="ifRelateDrp != null">
                e.inventory_id,
                IFNULL(e.material_num,0) inventoryNum,
            </if>
            <if test="ifRelateDrp == null">
                a.inventory_num,
            </if>
            a.person_limit,
            b.image_url
        FROM
            supermarket_product a
            LEFT JOIN menu_material b ON b.material_id = a.material_id
            LEFT JOIN drp_unit c ON c.unit_id = b.unit_id
            <if test="ifRelateDrp != null">
                LEFT JOIN supermarket_info d on d.supermarket_id = a.supermarket_id
                LEFT JOIN drp_inventory e on e.warehouse_id = d.warehouse_id and e.material_id = b.material_id
            </if>
        WHERE
            a.supermarket_id = #{content.supermarketId}
            AND a.material_id IN
            <foreach collection="content.materialIdList" item="materialId" separator="," open="(" close=")">
                #{materialId}
            </foreach>
    </select>
    <select id="getProductImg" resultType="com.bonus.canteen.core.supermarket.vo.SupermarketProductInfoImageVO">
        SELECT
        a.material_id,
        b.image_url as imgUrl
        FROM
        supermarket_product a
        left join menu_material b on a.material_id = b.material_id and b.del_flag = 2
        <where>
            <if test="goodsIdList != null and goodsIdList.size() > 0">
                and a.material_id in
                <foreach collection="goodsIdList" item="goodsId" separator="," open="(" close=")">
                    #{goodsId}
                </foreach>
            </if>
        </where>
    </select>
<!--    <select id="pageUnAddProduct" resultType="net.xnzn.core.supermarket.vo.SupermarketUnAddProductListVO">-->
<!--        SELECT-->
<!--        CONCAT( a.material_name, '/', c.unit_name ) showMaterial,-->
<!--        a.material_id,-->
<!--        a.material_name,-->
<!--        a.unit_id,-->
<!--        c.unit_name,-->
<!--        a.bar_code,-->
<!--        a.sale_price,-->
<!--        a.sale_price prefPrice,-->
<!--        a.image_url,-->
<!--        a.area_id,-->
<!--        d.area_name-->
<!--        FROM-->
<!--        menu_material a-->
<!--        LEFT JOIN supermarket_product b ON a.material_id = b.material_id-->
<!--        AND b.supermarket_id = #{content.supermarketId}-->
<!--        LEFT JOIN drp_unit c on c.unit_id = a.unit_id-->
<!--        left join alloc_area d on a.area_id = d.area_id-->
<!--        <where>-->
<!--            b.supermarket_detail_id is null-->
<!--            AND a.material_type = #{materialType}-->
<!--            AND a.del_flag = #{delFlag}-->
<!--            <if test="content.materialName != null and content.materialName != ''">-->
<!--                AND a.material_name like #{content.materialName}-->
<!--            </if>-->
<!--            <if test="content.barCode != null and content.barCode != ''">-->
<!--                AND a.bar_code like #{content.barCode}-->
<!--            </if>-->
<!--            <if test="content.categoryIdList != null and content.categoryIdList.size() > 0">-->
<!--                AND a.category_id in-->
<!--                <foreach collection="content.categoryIdList" item="categoryId" separator="," open="(" close=")">-->
<!--                    #{categoryId}-->
<!--                </foreach>-->
<!--            </if>-->
<!--            <if test="content.areaId != null">-->
<!--                AND (a.area_id = #{content.areaId} or a.area_id is null)-->
<!--            </if>-->
<!--        </where>-->
<!--    </select>-->


</mapper>
