<?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.prolog.upcloud.base.wh.operate.dao.WmsInvCheckHMapper">
    <update id="updateCheckDoneStatus">
        update wms_inv_check_h checkH
        SET status = 'DONE'
        where exists(select 1
        from WMS_INV_CHECK_D
        where CHECK_LINE_ID IN
        <foreach collection="dIds" open="(" close=")" separator="," item="id">
            #{id}
        </foreach>
        and CHECK_HEADER_ID = checkH.CHECK_HEADER_ID)
        and not exists(select 1
        from WMS_INV_CHECK_D
        where checkH.CHECK_HEADER_ID = CHECK_HEADER_ID
        and (STATUS = '0' or STATUS = '30'))
    </update>

    <update id="updateCheckNewStatus">
        update wms_inv_check_h checkH
        SET status = 'NEW'
        where exists(select 1
        from WMS_INV_CHECK_D
        where CHECK_LINE_ID IN
        <foreach collection="dIds" open="(" close=")" separator="," item="id">
            #{id}
        </foreach>
        and CHECK_HEADER_ID = checkH.CHECK_HEADER_ID)
    </update>
</mapper>
