<?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.neusoft.smart.pos.payorder.persistent.mapper.PayRefundOrderMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrder">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="refund_number" jdbcType="VARCHAR" property="refundNumber" />
    <result column="m_order_number" jdbcType="VARCHAR" property="mOrderNumber" />
    <result column="trade_id" jdbcType="VARCHAR" property="tradeId" />
    <result column="pay_refund_order_number" jdbcType="VARCHAR" property="payRefundOrderNumber" />
    <result column="mcode" jdbcType="VARCHAR" property="mcode" />
    <result column="outer_order_number" jdbcType="VARCHAR" property="outerOrderNumber" />
    <result column="pay_type" jdbcType="VARCHAR" property="payType" />
    <result column="pay_type_name" jdbcType="VARCHAR" property="payTypeName" />
    <result column="refund_notify_url" jdbcType="VARCHAR" property="refundNotifyUrl" />
    <result column="third_refund_number" jdbcType="VARCHAR" property="thirdRefundNumber" />
    <result column="refunded_amount" jdbcType="DECIMAL" property="refundedAmount" />
    <result column="refund_status" jdbcType="VARCHAR" property="refundStatus" />
    <result column="refunded_time" jdbcType="TIMESTAMP" property="refundedTime" />
    <result column="request_detail_info" jdbcType="VARCHAR" property="requestDetailInfo" />
    <result column="result_detail_info" jdbcType="VARCHAR" property="resultDetailInfo" />
    <result column="version" jdbcType="INTEGER" property="version" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <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">
    <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">
    id, refund_number, m_order_number, trade_id, pay_refund_order_number, mcode, outer_order_number, 
    pay_type, pay_type_name, refund_notify_url, third_refund_number, refunded_amount, 
    refund_status, refunded_time, request_detail_info, result_detail_info, version, created_at, 
    created_by, updated_by, updated_at
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrderExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from pay_refund_order_v2
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="offset != null and limit != null">
      limit ${offset}, ${limit}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from pay_refund_order_v2
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from pay_refund_order_v2
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrderExample">
    delete from pay_refund_order_v2
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrder" useGeneratedKeys="true">
    insert into pay_refund_order_v2 (refund_number, m_order_number, trade_id, 
      pay_refund_order_number, mcode, outer_order_number, 
      pay_type, pay_type_name, refund_notify_url, 
      third_refund_number, refunded_amount, refund_status, 
      refunded_time, request_detail_info, result_detail_info, 
      version, created_at, created_by, 
      updated_by, updated_at)
    values (#{refundNumber,jdbcType=VARCHAR}, #{mOrderNumber,jdbcType=VARCHAR}, #{tradeId,jdbcType=VARCHAR}, 
      #{payRefundOrderNumber,jdbcType=VARCHAR}, #{mcode,jdbcType=VARCHAR}, #{outerOrderNumber,jdbcType=VARCHAR}, 
      #{payType,jdbcType=VARCHAR}, #{payTypeName,jdbcType=VARCHAR}, #{refundNotifyUrl,jdbcType=VARCHAR}, 
      #{thirdRefundNumber,jdbcType=VARCHAR}, #{refundedAmount,jdbcType=DECIMAL}, #{refundStatus,jdbcType=VARCHAR}, 
      #{refundedTime,jdbcType=TIMESTAMP}, #{requestDetailInfo,jdbcType=VARCHAR}, #{resultDetailInfo,jdbcType=VARCHAR}, 
      #{version,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}, 
      #{updatedBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrder" useGeneratedKeys="true">
    insert into pay_refund_order_v2
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="refundNumber != null">
        refund_number,
      </if>
      <if test="mOrderNumber != null">
        m_order_number,
      </if>
      <if test="tradeId != null">
        trade_id,
      </if>
      <if test="payRefundOrderNumber != null">
        pay_refund_order_number,
      </if>
      <if test="mcode != null">
        mcode,
      </if>
      <if test="outerOrderNumber != null">
        outer_order_number,
      </if>
      <if test="payType != null">
        pay_type,
      </if>
      <if test="payTypeName != null">
        pay_type_name,
      </if>
      <if test="refundNotifyUrl != null">
        refund_notify_url,
      </if>
      <if test="thirdRefundNumber != null">
        third_refund_number,
      </if>
      <if test="refundedAmount != null">
        refunded_amount,
      </if>
      <if test="refundStatus != null">
        refund_status,
      </if>
      <if test="refundedTime != null">
        refunded_time,
      </if>
      <if test="requestDetailInfo != null">
        request_detail_info,
      </if>
      <if test="resultDetailInfo != null">
        result_detail_info,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="refundNumber != null">
        #{refundNumber,jdbcType=VARCHAR},
      </if>
      <if test="mOrderNumber != null">
        #{mOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="tradeId != null">
        #{tradeId,jdbcType=VARCHAR},
      </if>
      <if test="payRefundOrderNumber != null">
        #{payRefundOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="mcode != null">
        #{mcode,jdbcType=VARCHAR},
      </if>
      <if test="outerOrderNumber != null">
        #{outerOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="payType != null">
        #{payType,jdbcType=VARCHAR},
      </if>
      <if test="payTypeName != null">
        #{payTypeName,jdbcType=VARCHAR},
      </if>
      <if test="refundNotifyUrl != null">
        #{refundNotifyUrl,jdbcType=VARCHAR},
      </if>
      <if test="thirdRefundNumber != null">
        #{thirdRefundNumber,jdbcType=VARCHAR},
      </if>
      <if test="refundedAmount != null">
        #{refundedAmount,jdbcType=DECIMAL},
      </if>
      <if test="refundStatus != null">
        #{refundStatus,jdbcType=VARCHAR},
      </if>
      <if test="refundedTime != null">
        #{refundedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="requestDetailInfo != null">
        #{requestDetailInfo,jdbcType=VARCHAR},
      </if>
      <if test="resultDetailInfo != null">
        #{resultDetailInfo,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        #{version,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrderExample" resultType="java.lang.Integer">
    select count(*) from pay_refund_order_v2
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update pay_refund_order_v2
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.refundNumber != null">
        refund_number = #{record.refundNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.mOrderNumber != null">
        m_order_number = #{record.mOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.tradeId != null">
        trade_id = #{record.tradeId,jdbcType=VARCHAR},
      </if>
      <if test="record.payRefundOrderNumber != null">
        pay_refund_order_number = #{record.payRefundOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.mcode != null">
        mcode = #{record.mcode,jdbcType=VARCHAR},
      </if>
      <if test="record.outerOrderNumber != null">
        outer_order_number = #{record.outerOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.payType != null">
        pay_type = #{record.payType,jdbcType=VARCHAR},
      </if>
      <if test="record.payTypeName != null">
        pay_type_name = #{record.payTypeName,jdbcType=VARCHAR},
      </if>
      <if test="record.refundNotifyUrl != null">
        refund_notify_url = #{record.refundNotifyUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.thirdRefundNumber != null">
        third_refund_number = #{record.thirdRefundNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.refundedAmount != null">
        refunded_amount = #{record.refundedAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.refundStatus != null">
        refund_status = #{record.refundStatus,jdbcType=VARCHAR},
      </if>
      <if test="record.refundedTime != null">
        refunded_time = #{record.refundedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.requestDetailInfo != null">
        request_detail_info = #{record.requestDetailInfo,jdbcType=VARCHAR},
      </if>
      <if test="record.resultDetailInfo != null">
        result_detail_info = #{record.resultDetailInfo,jdbcType=VARCHAR},
      </if>
      <if test="record.version != null">
        version = #{record.version,jdbcType=INTEGER},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updatedBy != null">
        updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updatedAt != null">
        updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update pay_refund_order_v2
    set id = #{record.id,jdbcType=INTEGER},
      refund_number = #{record.refundNumber,jdbcType=VARCHAR},
      m_order_number = #{record.mOrderNumber,jdbcType=VARCHAR},
      trade_id = #{record.tradeId,jdbcType=VARCHAR},
      pay_refund_order_number = #{record.payRefundOrderNumber,jdbcType=VARCHAR},
      mcode = #{record.mcode,jdbcType=VARCHAR},
      outer_order_number = #{record.outerOrderNumber,jdbcType=VARCHAR},
      pay_type = #{record.payType,jdbcType=VARCHAR},
      pay_type_name = #{record.payTypeName,jdbcType=VARCHAR},
      refund_notify_url = #{record.refundNotifyUrl,jdbcType=VARCHAR},
      third_refund_number = #{record.thirdRefundNumber,jdbcType=VARCHAR},
      refunded_amount = #{record.refundedAmount,jdbcType=DECIMAL},
      refund_status = #{record.refundStatus,jdbcType=VARCHAR},
      refunded_time = #{record.refundedTime,jdbcType=TIMESTAMP},
      request_detail_info = #{record.requestDetailInfo,jdbcType=VARCHAR},
      result_detail_info = #{record.resultDetailInfo,jdbcType=VARCHAR},
      version = #{record.version,jdbcType=INTEGER},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=VARCHAR},
      updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrder">
    update pay_refund_order_v2
    <set>
      <if test="refundNumber != null">
        refund_number = #{refundNumber,jdbcType=VARCHAR},
      </if>
      <if test="mOrderNumber != null">
        m_order_number = #{mOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="tradeId != null">
        trade_id = #{tradeId,jdbcType=VARCHAR},
      </if>
      <if test="payRefundOrderNumber != null">
        pay_refund_order_number = #{payRefundOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="mcode != null">
        mcode = #{mcode,jdbcType=VARCHAR},
      </if>
      <if test="outerOrderNumber != null">
        outer_order_number = #{outerOrderNumber,jdbcType=VARCHAR},
      </if>
      <if test="payType != null">
        pay_type = #{payType,jdbcType=VARCHAR},
      </if>
      <if test="payTypeName != null">
        pay_type_name = #{payTypeName,jdbcType=VARCHAR},
      </if>
      <if test="refundNotifyUrl != null">
        refund_notify_url = #{refundNotifyUrl,jdbcType=VARCHAR},
      </if>
      <if test="thirdRefundNumber != null">
        third_refund_number = #{thirdRefundNumber,jdbcType=VARCHAR},
      </if>
      <if test="refundedAmount != null">
        refunded_amount = #{refundedAmount,jdbcType=DECIMAL},
      </if>
      <if test="refundStatus != null">
        refund_status = #{refundStatus,jdbcType=VARCHAR},
      </if>
      <if test="refundedTime != null">
        refunded_time = #{refundedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="requestDetailInfo != null">
        request_detail_info = #{requestDetailInfo,jdbcType=VARCHAR},
      </if>
      <if test="resultDetailInfo != null">
        result_detail_info = #{resultDetailInfo,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        version = #{version,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.payorder.persistent.domain.PayRefundOrder">
    update pay_refund_order_v2
    set refund_number = #{refundNumber,jdbcType=VARCHAR},
      m_order_number = #{mOrderNumber,jdbcType=VARCHAR},
      trade_id = #{tradeId,jdbcType=VARCHAR},
      pay_refund_order_number = #{payRefundOrderNumber,jdbcType=VARCHAR},
      mcode = #{mcode,jdbcType=VARCHAR},
      outer_order_number = #{outerOrderNumber,jdbcType=VARCHAR},
      pay_type = #{payType,jdbcType=VARCHAR},
      pay_type_name = #{payTypeName,jdbcType=VARCHAR},
      refund_notify_url = #{refundNotifyUrl,jdbcType=VARCHAR},
      third_refund_number = #{thirdRefundNumber,jdbcType=VARCHAR},
      refunded_amount = #{refundedAmount,jdbcType=DECIMAL},
      refund_status = #{refundStatus,jdbcType=VARCHAR},
      refunded_time = #{refundedTime,jdbcType=TIMESTAMP},
      request_detail_info = #{requestDetailInfo,jdbcType=VARCHAR},
      result_detail_info = #{resultDetailInfo,jdbcType=VARCHAR},
      version = #{version,jdbcType=INTEGER},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=VARCHAR},
      updated_by = #{updatedBy,jdbcType=VARCHAR},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into pay_refund_order_v2  (refund_number, m_order_number, trade_id, 
        pay_refund_order_number, mcode, outer_order_number, 
        pay_type, pay_type_name, refund_notify_url, 
        third_refund_number, refunded_amount, refund_status, 
        refunded_time, request_detail_info, result_detail_info, 
        version, created_at, created_by, 
        updated_by, updated_at)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.refundNumber,jdbcType=VARCHAR}, #{item.mOrderNumber,jdbcType=VARCHAR}, #{item.tradeId,jdbcType=VARCHAR}, 
        #{item.payRefundOrderNumber,jdbcType=VARCHAR}, #{item.mcode,jdbcType=VARCHAR}, #{item.outerOrderNumber,jdbcType=VARCHAR}, 
        #{item.payType,jdbcType=VARCHAR}, #{item.payTypeName,jdbcType=VARCHAR}, #{item.refundNotifyUrl,jdbcType=VARCHAR}, 
        #{item.thirdRefundNumber,jdbcType=VARCHAR}, #{item.refundedAmount,jdbcType=DECIMAL}, #{item.refundStatus,jdbcType=VARCHAR}, 
        #{item.refundedTime,jdbcType=TIMESTAMP}, #{item.requestDetailInfo,jdbcType=VARCHAR}, #{item.resultDetailInfo,jdbcType=VARCHAR}, 
        #{item.version,jdbcType=INTEGER}, #{item.createdAt,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=VARCHAR}, 
        #{item.updatedBy,jdbcType=VARCHAR}, #{item.updatedAt,jdbcType=TIMESTAMP})
      </foreach>
    </if>
  </insert>
</mapper>