<?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.yonge.cooleshow.mbg.mapper.UserOrderRefundMapper">
  <resultMap id="BaseResultMap" type="com.yonge.cooleshow.mbg.model.UserOrderRefund">
    <!--@mbg.generated-->
    <!--@Table user_order_refund-->
    <id column="id_" jdbcType="BIGINT" property="id" />
    <result column="return_id_" jdbcType="VARCHAR" property="returnId" />
    <result column="order_no_" jdbcType="VARCHAR" property="orderNo" />
    <result column="trans_no_" jdbcType="VARCHAR" property="transNo" />
    <result column="pay_trans_no_" jdbcType="VARCHAR" property="payTransNo" />
    <result column="pay_order_no_" jdbcType="VARCHAR" property="payOrderNo" />
    <result column="refund_amt_" jdbcType="DECIMAL" property="refundAmt" />
    <result column="fee_amt_" jdbcType="DECIMAL" property="feeAmt" />
    <result column="status_" jdbcType="VARCHAR" property="status" />
    <result column="pay_fail_msg_" jdbcType="VARCHAR" property="payFailMsg" />
    <result column="arrival_time_" jdbcType="TIMESTAMP" property="arrivalTime" />
    <result column="create_time_" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--@mbg.generated-->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--@mbg.generated-->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id_, order_no_, trans_no_, pay_trans_no_, refund_amt_, fee_amt_, status_, pay_fail_msg_, 
    arrival_time_, create_time_, update_time_,return_id_,pay_order_no_
  </sql>
  <select id="selectByExample" parameterType="com.yonge.cooleshow.mbg.model.UserOrderRefundExample" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from user_order_refund
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from user_order_refund
    where id_ = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from user_order_refund
    where id_ = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.yonge.cooleshow.mbg.model.UserOrderRefundExample">
    <!--@mbg.generated-->
    delete from user_order_refund
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.yonge.cooleshow.mbg.model.UserOrderRefund" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into user_order_refund (order_no_, trans_no_, pay_trans_no_, 
      refund_amt_, fee_amt_, status_, 
      pay_fail_msg_, arrival_time_, create_time_, 
      update_time_,return_id_,pay_order_no_)
    values (#{orderNo,jdbcType=VARCHAR}, #{transNo,jdbcType=VARCHAR}, #{payTransNo,jdbcType=VARCHAR}, 
      #{refundAmt,jdbcType=DECIMAL}, #{feeAmt,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, 
      #{payFailMsg,jdbcType=VARCHAR}, #{arrivalTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateTime,jdbcType=TIMESTAMP},#{returnId},#{payOrderNo})
  </insert>
  <insert id="insertSelective" keyColumn="id_" keyProperty="id" parameterType="com.yonge.cooleshow.mbg.model.UserOrderRefund" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into user_order_refund
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderNo != null">
        order_no_,
      </if>
      <if test="transNo != null">
        trans_no_,
      </if>
      <if test="payTransNo != null">
        pay_trans_no_,
      </if>
      <if test="refundAmt != null">
        refund_amt_,
      </if>
      <if test="feeAmt != null">
        fee_amt_,
      </if>
      <if test="status != null">
        status_,
      </if>
      <if test="payFailMsg != null">
        pay_fail_msg_,
      </if>
      <if test="arrivalTime != null">
        arrival_time_,
      </if>
      <if test="createTime != null">
        create_time_,
      </if>
      <if test="updateTime != null">
        update_time_,
      </if>
      <if test="returnId != null">
        return_id_,
      </if>
      <if test="payOrderNo != null">
        pay_order_no_,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderNo != null">
        #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="transNo != null">
        #{transNo,jdbcType=VARCHAR},
      </if>
      <if test="payTransNo != null">
        #{payTransNo,jdbcType=VARCHAR},
      </if>
      <if test="refundAmt != null">
        #{refundAmt,jdbcType=DECIMAL},
      </if>
      <if test="feeAmt != null">
        #{feeAmt,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="payFailMsg != null">
        #{payFailMsg,jdbcType=VARCHAR},
      </if>
      <if test="arrivalTime != null">
        #{arrivalTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="returnId != null">
        #{returnId},
      </if>
      <if test="payOrderNo != null">
        #{payOrderNo},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.yonge.cooleshow.mbg.model.UserOrderRefundExample" resultType="java.lang.Long">
    <!--@mbg.generated-->
    select count(*) from user_order_refund
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--@mbg.generated-->
    update user_order_refund
    <set>
      <if test="record.id != null">
        id_ = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.orderNo != null">
        order_no_ = #{record.orderNo,jdbcType=VARCHAR},
      </if>
      <if test="record.transNo != null">
        trans_no_ = #{record.transNo,jdbcType=VARCHAR},
      </if>
      <if test="record.payTransNo != null">
        pay_trans_no_ = #{record.payTransNo,jdbcType=VARCHAR},
      </if>
      <if test="record.refundAmt != null">
        refund_amt_ = #{record.refundAmt,jdbcType=DECIMAL},
      </if>
      <if test="record.feeAmt != null">
        fee_amt_ = #{record.feeAmt,jdbcType=DECIMAL},
      </if>
      <if test="record.status != null">
        status_ = #{record.status,jdbcType=VARCHAR},
      </if>
      <if test="record.payFailMsg != null">
        pay_fail_msg_ = #{record.payFailMsg,jdbcType=VARCHAR},
      </if>
      <if test="record.arrivalTime != null">
        arrival_time_ = #{record.arrivalTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createTime != null">
        create_time_ = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateTime != null">
        update_time_ = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.returnId != null">
        return_id_ = #{record.returnId,jdbcType=BIGINT},
      </if>
      <if test="record.payOrderNo != null">
        pay_order_no_ = #{record.payOrderNo,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--@mbg.generated-->
    update user_order_refund
    set id_ = #{record.id,jdbcType=BIGINT},
      order_no_ = #{record.orderNo,jdbcType=VARCHAR},
      trans_no_ = #{record.transNo,jdbcType=VARCHAR},
      pay_trans_no_ = #{record.payTransNo,jdbcType=VARCHAR},
      refund_amt_ = #{record.refundAmt,jdbcType=DECIMAL},
      fee_amt_ = #{record.feeAmt,jdbcType=DECIMAL},
      status_ = #{record.status,jdbcType=VARCHAR},
      pay_fail_msg_ = #{record.payFailMsg,jdbcType=VARCHAR},
      arrival_time_ = #{record.arrivalTime,jdbcType=TIMESTAMP},
      create_time_ = #{record.createTime,jdbcType=TIMESTAMP},
      return_id_ = #{record.returnId,jdbcType=BIGINT},
      pay_order_no_ = #{record.payOrderNo},
      update_time_ = #{record.updateTime,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yonge.cooleshow.mbg.model.UserOrderRefund">
    <!--@mbg.generated-->
    update user_order_refund
    <set>
      <if test="orderNo != null">
        order_no_ = #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="transNo != null">
        trans_no_ = #{transNo,jdbcType=VARCHAR},
      </if>
      <if test="payTransNo != null">
        pay_trans_no_ = #{payTransNo,jdbcType=VARCHAR},
      </if>
      <if test="refundAmt != null">
        refund_amt_ = #{refundAmt,jdbcType=DECIMAL},
      </if>
      <if test="feeAmt != null">
        fee_amt_ = #{feeAmt,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        status_ = #{status,jdbcType=VARCHAR},
      </if>
      <if test="payFailMsg != null">
        pay_fail_msg_ = #{payFailMsg,jdbcType=VARCHAR},
      </if>
      <if test="arrivalTime != null">
        arrival_time_ = #{arrivalTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createTime != null">
        create_time_ = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time_ = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="returnId != null">
        return_id_ = #{returnId,jdbcType=BIGINT},
      </if>
      <if test="payOrderNo != null">
        pay_order_no_ = #{payOrderNo},
      </if>
    </set>
    where id_ = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yonge.cooleshow.mbg.model.UserOrderRefund">
    <!--@mbg.generated-->
    update user_order_refund
    set order_no_ = #{orderNo,jdbcType=VARCHAR},
      trans_no_ = #{transNo,jdbcType=VARCHAR},
      pay_trans_no_ = #{payTransNo,jdbcType=VARCHAR},
      refund_amt_ = #{refundAmt,jdbcType=DECIMAL},
      fee_amt_ = #{feeAmt,jdbcType=DECIMAL},
      status_ = #{status,jdbcType=VARCHAR},
      pay_fail_msg_ = #{payFailMsg,jdbcType=VARCHAR},
      arrival_time_ = #{arrivalTime,jdbcType=TIMESTAMP},
      create_time_ = #{createTime,jdbcType=TIMESTAMP},
      return_id_ = #{returnId,jdbcType=BIGINT},
      pay_order_no_ = #{payOrderNo},
      update_time_ = #{updateTime,jdbcType=TIMESTAMP}
    where id_ = #{id,jdbcType=BIGINT}
  </update>

  <select id="selectByTransNo" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user_order_refund
    where #{transNo} = trans_no_ limit 1
  </select>

  <select id="selectByRefundNo" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user_order_refund
    where #{refundOrderNo} = order_no_ limit 1
    </select>

  <select id="selectByPayOrderNo" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user_order_refund
    where #{payOrderNo} = pay_order_no_   and status_ = 'succeeded'
  </select>
</mapper>