<?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.OrderRefundInterventionMapper">
  <resultMap id="orderRefundInterventionMap" type="com.tmerclub.cloud.order.model.OrderRefundIntervention">
    <id column="refund_intervertion_id" property="refundIntervertionId" />
    <result column="refund_id" property="refundId"/>
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
    <result column="biz_id" property="bizId"/>
    <result column="sys_type" property="sysType"/>
    <result column="voucher_desc" property="voucherDesc"/>
    <result column="img_urls" property="imgUrls"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `refund_intervertion_id`,`refund_id`,`create_time`,`update_time`,`biz_id`,`sys_type`,`voucher_desc`,`img_urls`
  </sql>
  <select id="listByRefundId" resultType="com.tmerclub.cloud.order.vo.OrderRefundInterventionVO">
    select <include refid="Vo_Column_List"/> from order_refund_intervention
    where refund_id = #{refundId}
    order by refund_intervertion_id desc
  </select>
  <select id="getByRefundIntervertionId" resultMap="orderRefundInterventionMap">
    select <include refid="Vo_Column_List"/> from order_refund_intervention where refund_intervertion_id = #{refundIntervertionId}
  </select>
  <insert id="save">
    insert into order_refund_intervention (`refund_id`,`biz_id`,`sys_type`,`voucher_desc`,`img_urls`)
    values
    (#{orderRefundIntervention.refundId},#{orderRefundIntervention.bizId},#{orderRefundIntervention.sysType},#{orderRefundIntervention.voucherDesc},#{orderRefundIntervention.imgUrls});
  </insert>
  <update id="update">
    update order_refund_intervention
    <set>
      <if test="orderRefundIntervention.refundId != null">
        `refund_id` = #{orderRefundIntervention.refundId},
      </if>
      <if test="orderRefundIntervention.bizId != null">
        `biz_id` = #{orderRefundIntervention.bizId},
      </if>
      <if test="orderRefundIntervention.sysType != null">
        `sys_type` = #{orderRefundIntervention.sysType},
      </if>
      <if test="orderRefundIntervention.voucherDesc != null">
        `voucher_desc` = #{orderRefundIntervention.voucherDesc},
      </if>
      <if test="orderRefundIntervention.imgUrls != null">
        `img_urls` = #{orderRefundIntervention.imgUrls},
      </if>
    </set>
    where refund_intervertion_id = #{orderRefundIntervention.refundIntervertionId}
  </update>
  <delete id="deleteById">
    delete from order_refund_intervention where refund_id = #{refundId}
  </delete>

</mapper>
