<?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.tmerclub.cloud.order.mapper.OrderReturnReasonMapper">
  <resultMap id="orderReturnReasonMap" type="com.tmerclub.cloud.order.model.OrderReturnReason">
    <id column="reason_id" property="reasonId" />
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
    <result column="reason" property="reason"/>
    <result column="seq" property="seq"/>
    <result column="status" property="status"/>
    <result column="reduce_amount" property="reduceAmount"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `reason_id`,`create_time`,`update_time`,`reason`,`seq`,`status`,`reduce_amount`
  </sql>
  <select id="list" resultType="com.tmerclub.cloud.order.vo.OrderReturnReasonVO">
    select <include refid="Vo_Column_List"/> from order_return_reason order by reason_id desc
  </select>
  <select id="getByReasonId" resultType="com.tmerclub.cloud.order.vo.OrderReturnReasonVO">
    select <include refid="Vo_Column_List"/> from order_return_reason where reason_id = #{reasonId}
  </select>
  <insert id="save">
    insert into order_return_reason (`reason`,`seq`,`status`,`reduce_amount`)
    values (#{orderReturnReason.reason},#{orderReturnReason.seq},#{orderReturnReason.status},#{orderReturnReason.reduceAmount});
  </insert>
  <update id="update">
    update order_return_reason
    <set>
      <if test="orderReturnReason.reason != null">
        `reason` = #{orderReturnReason.reason},
      </if>
      <if test="orderReturnReason.seq != null">
        `seq` = #{orderReturnReason.seq},
      </if>
      <if test="orderReturnReason.status != null">
        `status` = #{orderReturnReason.status},
      </if>
      <if test="orderReturnReason.reduceAmount != null">
        `reduce_amount` = #{orderReturnReason.reduceAmount},
      </if>
    </set>
    where reason_id = #{orderReturnReason.reasonId}
  </update>
  <delete id="deleteById">
    delete from order_return_reason where reason_id = #{reasonId}
  </delete>

</mapper>
