<?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.buy507.mall.mapper.UmsMemberAccountTransactionMapper">
  <resultMap id="BaseResultMap" type="com.buy507.mall.model.UmsMemberAccountTransaction">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="member_id" jdbcType="BIGINT" property="memberId" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="revenue_amount" jdbcType="DECIMAL" property="revenueAmount" />
    <result column="transaction_state" jdbcType="INTEGER" property="transactionState" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="commission_ratio" jdbcType="INTEGER" property="commissionRatio" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="transfer_payment_time" jdbcType="TIMESTAMP" property="transferPaymentTime" />
  </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, member_id, order_id, revenue_amount, transaction_state, remarks, commission_ratio, 
    create_time, transfer_payment_time
  </sql>
  <select id="selectByExample" parameterType="com.buy507.mall.model.UmsMemberAccountTransactionExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from ums_member_account_transaction
    <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">
    select 
    <include refid="Base_Column_List" />
    from ums_member_account_transaction
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ums_member_account_transaction
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.buy507.mall.model.UmsMemberAccountTransactionExample">
    delete from ums_member_account_transaction
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.buy507.mall.model.UmsMemberAccountTransaction">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into ums_member_account_transaction (member_id, order_id, revenue_amount, 
      transaction_state, remarks, commission_ratio,  transfer_payment_time, revenue_points)
    values (#{memberId,jdbcType=BIGINT}, #{orderId,jdbcType=BIGINT}, #{revenueAmount,jdbcType=DECIMAL}, 
      #{transactionState,jdbcType=INTEGER}, #{remarks,jdbcType=VARCHAR}, #{commissionRatio,jdbcType=INTEGER}, 
      #{transferPaymentTime,jdbcType=TIMESTAMP}, #{revenuePoints,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.buy507.mall.model.UmsMemberAccountTransaction">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into ums_member_account_transaction
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="memberId != null">
        member_id,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="revenueAmount != null">
        revenue_amount,
      </if>
      <if test="transactionState != null">
        transaction_state,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
      <if test="commissionRatio != null">
        commission_ratio,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="transferPaymentTime != null">
        transfer_payment_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="memberId != null">
        #{memberId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="revenueAmount != null">
        #{revenueAmount,jdbcType=DECIMAL},
      </if>
      <if test="transactionState != null">
        #{transactionState,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="commissionRatio != null">
        #{commissionRatio,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="transferPaymentTime != null">
        #{transferPaymentTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.buy507.mall.model.UmsMemberAccountTransactionExample" resultType="java.lang.Long">
    select count(*) from ums_member_account_transaction
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update ums_member_account_transaction
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.memberId != null">
        member_id = #{record.memberId,jdbcType=BIGINT},
      </if>
      <if test="record.orderId != null">
        order_id = #{record.orderId,jdbcType=BIGINT},
      </if>
      <if test="record.revenueAmount != null">
        revenue_amount = #{record.revenueAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.transactionState != null">
        transaction_state = #{record.transactionState,jdbcType=INTEGER},
      </if>
      <if test="record.remarks != null">
        remarks = #{record.remarks,jdbcType=VARCHAR},
      </if>
      <if test="record.commissionRatio != null">
        commission_ratio = #{record.commissionRatio,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.transferPaymentTime != null">
        transfer_payment_time = #{record.transferPaymentTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update ums_member_account_transaction
    set id = #{record.id,jdbcType=BIGINT},
      member_id = #{record.memberId,jdbcType=BIGINT},
      order_id = #{record.orderId,jdbcType=BIGINT},
      revenue_amount = #{record.revenueAmount,jdbcType=DECIMAL},
      transaction_state = #{record.transactionState,jdbcType=INTEGER},
      remarks = #{record.remarks,jdbcType=VARCHAR},
      commission_ratio = #{record.commissionRatio,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      transfer_payment_time = #{record.transferPaymentTime,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.buy507.mall.model.UmsMemberAccountTransaction">
    update ums_member_account_transaction
    <set>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="revenueAmount != null">
        revenue_amount = #{revenueAmount,jdbcType=DECIMAL},
      </if>
      <if test="transactionState != null">
        transaction_state = #{transactionState,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="commissionRatio != null">
        commission_ratio = #{commissionRatio,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="transferPaymentTime != null">
        transfer_payment_time = #{transferPaymentTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.buy507.mall.model.UmsMemberAccountTransaction">
    update ums_member_account_transaction
    set member_id = #{memberId,jdbcType=BIGINT},
      order_id = #{orderId,jdbcType=BIGINT},
      revenue_amount = #{revenueAmount,jdbcType=DECIMAL},
      transaction_state = #{transactionState,jdbcType=INTEGER},
      remarks = #{remarks,jdbcType=VARCHAR},
      commission_ratio = #{commissionRatio,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      transfer_payment_time = #{transferPaymentTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>