<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gree.mall.manager.commonmapper.MaterialGoodsStockCMapper">

    <select id="queryExistWebsitStockList" resultType="com.gree.mall.manager.plus.entity.WebsitStock">
        SELECT
        *
        FROM
        websit_stock
        WHERE
        company_wechat_id = #{companyWechatId}
        AND
        websit_id = #{websitId}
        AND
        storage_id = #{storageId}
        AND
        goods_id IN
        <foreach item="item" index="index" collection="stockList" open="(" separator=","
                 close=")">
            #{item.goodsId}
        </foreach>
        FOR UPDATE
    </select>

    <select id="queryExistWorkerStockList" resultType="com.gree.mall.manager.plus.entity.WorkerStock">
        SELECT
        *
        FROM
        worker_stock
        WHERE
        company_wechat_id = #{dto.companyWechatId}
        AND
        identity = #{dto.identity}
        AND
        goods_id IN
        <foreach item="item" index="index" collection="stockList" open="(" separator=","
                 close=")">
            #{item.goodsId}
        </foreach>
        FOR UPDATE
    </select>

    <select id="querySalesItemByItemId" resultType="com.gree.mall.manager.plus.entity.WebsitPartsSalesItem">
        SELECT
        a.*
        FROM
        websit_parts_sales_item a
        WHERE
            a.company_wechat_id = #{companyWechatId}
            AND a.identity = #{identity}
            AND a.websit_id = #{websitId}
            AND a.parts_websit_id = #{partsWebsitId}
            AND a.id IN
            <foreach item="item" index="index" collection="records" open="(" separator=","
                     close=")">
                #{item}
            </foreach>
        FOR UPDATE
    </select>
</mapper>