<?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.jsowell.pile.mapper.OrderPayRecordMapper">
  <resultMap id="BaseResultMap" type="com.jsowell.pile.domain.OrderPayRecord">
    <!--@mbg.generated-->
    <!--@Table order_pay_record-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="order_code" jdbcType="VARCHAR" property="orderCode" />
    <result column="pay_mode" jdbcType="VARCHAR" property="payMode" />
    <result column="pay_amount" jdbcType="DECIMAL" property="payAmount" />
    <result column="payment_id" jdbcType="VARCHAR" property="paymentId" />
    <result column="acquirer" jdbcType="VARCHAR" property="acquirer" />
    <result column="refund_amount" jdbcType="DECIMAL" property="refundAmount" />
    <result column="deduction_record" jdbcType="VARCHAR" property="deductionRecord" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="del_flag" jdbcType="CHAR" property="delFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, order_code, pay_mode, pay_amount, payment_id, acquirer, refund_amount, deduction_record, 
    create_by, create_time, update_by, update_time, del_flag
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from order_pay_record
    where id = #{id,jdbcType=INTEGER}
  </select>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderPayRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_pay_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderCode != null">
        order_code,
      </if>
      <if test="payMode != null">
        pay_mode,
      </if>
      <if test="payAmount != null">
        pay_amount,
      </if>
      <if test="paymentId != null">
        payment_id,
      </if>
      <if test="acquirer != null">
        acquirer,
      </if>
      <if test="refundAmount != null">
        refund_amount,
      </if>
      <if test="deductionRecord != null">
        deduction_record,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderCode != null">
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="paymentId != null">
        #{paymentId,jdbcType=VARCHAR},
      </if>
      <if test="acquirer != null">
        #{acquirer,jdbcType=VARCHAR},
      </if>
      <if test="refundAmount != null">
        #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="deductionRecord != null">
        #{deductionRecord,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.OrderPayRecord">
    <!--@mbg.generated-->
    update order_pay_record
    <set>
      <if test="orderCode != null">
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        pay_mode = #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        pay_amount = #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="paymentId != null">
        payment_id = #{paymentId,jdbcType=VARCHAR},
      </if>
      <if test="acquirer != null">
        acquirer = #{acquirer,jdbcType=VARCHAR},
      </if>
      <if test="refundAmount != null">
        refund_amount = #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="deductionRecord != null">
        deduction_record = #{deductionRecord,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=CHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update order_pay_record
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="order_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.orderCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="pay_mode = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.payMode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="pay_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.payAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="payment_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.paymentId,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="acquirer = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.acquirer,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="refund_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.refundAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="deduction_record = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.deductionRecord,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="update_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="update_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="del_flag = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.delFlag,jdbcType=CHAR}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_pay_record
    (order_code, pay_mode, pay_amount, payment_id, acquirer, refund_amount, deduction_record, 
      create_by, create_time, update_by, update_time, del_flag)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.orderCode,jdbcType=VARCHAR}, #{item.payMode,jdbcType=VARCHAR}, #{item.payAmount,jdbcType=DECIMAL}, 
        #{item.paymentId,jdbcType=VARCHAR}, #{item.acquirer,jdbcType=VARCHAR}, #{item.refundAmount,jdbcType=DECIMAL}, 
        #{item.deductionRecord,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
        #{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.delFlag,jdbcType=CHAR}
        )
    </foreach>
  </insert>
  <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderPayRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_pay_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      order_code,
      pay_mode,
      pay_amount,
      payment_id,
      acquirer,
      refund_amount,
      deduction_record,
      create_by,
      create_time,
      update_by,
      update_time,
      del_flag,
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      #{orderCode,jdbcType=VARCHAR},
      #{payMode,jdbcType=VARCHAR},
      #{payAmount,jdbcType=DECIMAL},
      #{paymentId,jdbcType=VARCHAR},
      #{acquirer,jdbcType=VARCHAR},
      #{refundAmount,jdbcType=DECIMAL},
      #{deductionRecord,jdbcType=VARCHAR},
      #{createBy,jdbcType=VARCHAR},
      #{createTime,jdbcType=TIMESTAMP},
      #{updateBy,jdbcType=VARCHAR},
      #{updateTime,jdbcType=TIMESTAMP},
      #{delFlag,jdbcType=CHAR},
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      order_code = #{orderCode,jdbcType=VARCHAR},
      pay_mode = #{payMode,jdbcType=VARCHAR},
      pay_amount = #{payAmount,jdbcType=DECIMAL},
      payment_id = #{paymentId,jdbcType=VARCHAR},
      acquirer = #{acquirer,jdbcType=VARCHAR},
      refund_amount = #{refundAmount,jdbcType=DECIMAL},
      deduction_record = #{deductionRecord,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      del_flag = #{delFlag,jdbcType=CHAR},
    </trim>
  </insert>
  <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderPayRecord" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_pay_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="orderCode != null">
        order_code,
      </if>
      <if test="payMode != null">
        pay_mode,
      </if>
      <if test="payAmount != null">
        pay_amount,
      </if>
      <if test="paymentId != null">
        payment_id,
      </if>
      <if test="acquirer != null">
        acquirer,
      </if>
      <if test="refundAmount != null">
        refund_amount,
      </if>
      <if test="deductionRecord != null">
        deduction_record,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="orderCode != null">
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="paymentId != null">
        #{paymentId,jdbcType=VARCHAR},
      </if>
      <if test="acquirer != null">
        #{acquirer,jdbcType=VARCHAR},
      </if>
      <if test="refundAmount != null">
        #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="deductionRecord != null">
        #{deductionRecord,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      <if test="orderCode != null">
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        pay_mode = #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        pay_amount = #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="paymentId != null">
        payment_id = #{paymentId,jdbcType=VARCHAR},
      </if>
      <if test="acquirer != null">
        acquirer = #{acquirer,jdbcType=VARCHAR},
      </if>
      <if test="refundAmount != null">
        refund_amount = #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="deductionRecord != null">
        deduction_record = #{deductionRecord,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
  </insert>

  <select id="getOrderPayRecordList" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from order_pay_record
    where order_code = #{orderCode,jdbcType=VARCHAR}
  </select>
</mapper>