<?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.xingxi.mq.server.order.mapper.OrderDetailMqMapper">

    <select id="checkOrderFinished" resultType="int">
		select count(1) from t_order_detail
		where orderId = #{orderId}
            and orderDetailStatus not in ('CANCELLED', 'REJECTED', 'FINISHED')
	</select>

    <update id="updateReturnQty" parameterType="OrderDetail">
        update t_order_detail set afterQty = afterQty - afterQty,
                                  returnQty = returnQty + #{returnQty},
                                  updateUser = #{updateUser},
                                  updateTime = #{updateTime}
        where 1 = 1
            <if test="orderId != null "> and orderId = #{orderId}</if>
            <if test="orderDetailId != null "> and orderDetailId = #{orderDetailId}</if>
            <if test="suiteId != null and suiteId != ''"> and suiteId = #{suiteId}</if>
    </update>

</mapper>