<?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.material.part.mapper.PartCheckMapper">

    <update id="batchUpdateDetailsTaskStatus">
        update purchase_part_details
        set status = #{newTaskStatus}
        where task_id = #{taskId}
    </update>

    <update id="updatePurchaseDetails4Check">
        update
        purchase_part_details
        <set>
            `status` = #{status},check_result = #{checkResult},check_time = NOW(),
            <if test="status != null and status == 4">
                check_num = purchase_num,
            </if>
            <if test="checkUser != null">
                check_user = #{checkUser}
            </if>
        </set>
        <where>
            <if test="taskId != null">
                and task_id = #{taskId}
            </if>
            <if test="partId != null">
                and part_id = #{partId}
            </if>
        </where>
    </update>
</mapper>