<?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.yd.dal.mapper.customer.CustomerFortuneMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.CustomerFortune">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="share_id" jdbcType="BIGINT" property="shareId" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="order_date" jdbcType="TIMESTAMP" property="orderDate" />
    <result column="order_price" jdbcType="DECIMAL" property="orderPrice" />
    <result column="referral_rate" jdbcType="DECIMAL" property="referralRate" />
    <result column="referral_amount" jdbcType="DECIMAL" property="referralAmount" />
    <result column="is_tax" jdbcType="INTEGER" property="isTax" />
    <result column="tax_amount" jdbcType="DECIMAL" property="taxAmount" />
    <result column="net_amount" jdbcType="DECIMAL" property="netAmount" />
    <result column="campaign_id" jdbcType="BIGINT" property="campaignId" />
    <result column="withdrawable_date" jdbcType="TIMESTAMP" property="withdrawableDate" />
    <result column="withdrawed_id" jdbcType="BIGINT" property="withdrawedId" />
    <result column="fortune_payed_id" jdbcType="BIGINT" property="fortunePayedId" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
  </resultMap>
  <sql id="Base_Column_List">
    id, share_id, customer_id, order_id, order_date, order_price, referral_rate, referral_amount, 
     is_tax, tax_amount, net_amount, campaign_id, withdrawable_date,
    withdrawed_id, fortune_payed_id, created_at, created_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_acl_customer_fortune
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="selectByCustomerId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_acl_customer_fortune
    where customer_id = #{CustomerId,jdbcType=BIGINT}
  </select>  
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_customer_fortune
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.yd.dal.entity.customer.CustomerFortune">
    insert into ag_acl_customer_fortune (id, share_id, customer_id, 
      order_id, order_date, order_price, 
      referral_rate, referral_amount,
      is_tax, tax_amount, net_amount, 
      campaign_id, withdrawable_date, withdrawed_id, 
      fortune_payed_id, created_at, created_by
      )
    values (#{id,jdbcType=BIGINT}, #{shareId,jdbcType=BIGINT}, #{customerId,jdbcType=BIGINT}, 
      #{orderId,jdbcType=BIGINT}, #{orderDate,jdbcType=TIMESTAMP}, #{orderPrice,jdbcType=DECIMAL}, 
      #{referralRate,jdbcType=DECIMAL}, #{referralAmount,jdbcType=DECIMAL},
      #{isTax,jdbcType=INTEGER}, #{taxAmount,jdbcType=DECIMAL}, #{netAmount,jdbcType=DECIMAL}, 
      #{campaignId,jdbcType=BIGINT}, #{withdrawableDate,jdbcType=TIMESTAMP}, #{withdrawedId,jdbcType=BIGINT}, 
      #{fortunePayedId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.yd.dal.entity.customer.CustomerFortune">
    insert into ag_acl_customer_fortune
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="shareId != null">
        share_id,
      </if>
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="orderDate != null">
        order_date,
      </if>
      <if test="orderPrice != null">
        order_price,
      </if>
      <if test="referralRate != null">
        referral_rate,
      </if>
      <if test="referralAmount != null">
        referral_amount,
      </if>
      <if test="isTax != null">
        is_tax,
      </if>
      <if test="taxAmount != null">
        tax_amount,
      </if>
      <if test="netAmount != null">
        net_amount,
      </if>
      <if test="campaignId != null">
        campaign_id,
      </if>
      <if test="withdrawableDate != null">
        withdrawable_date,
      </if>
      <if test="withdrawedId != null">
        withdrawed_id,
      </if>
      <if test="fortunePayedId != null">
        fortune_payed_id,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="shareId != null">
        #{shareId,jdbcType=BIGINT},
      </if>
      <if test="customerId != null">
        #{customerId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="orderDate != null">
        #{orderDate,jdbcType=TIMESTAMP},
      </if>
      <if test="orderPrice != null">
        #{orderPrice,jdbcType=DECIMAL},
      </if>
      <if test="referralRate != null">
        #{referralRate,jdbcType=DECIMAL},
      </if>
      <if test="referralAmount != null">
        #{referralAmount,jdbcType=DECIMAL},
      </if>
      <if test="isTax != null">
        #{isTax,jdbcType=INTEGER},
      </if>
      <if test="taxAmount != null">
        #{taxAmount,jdbcType=DECIMAL},
      </if>
      <if test="netAmount != null">
        #{netAmount,jdbcType=DECIMAL},
      </if>
      <if test="campaignId != null">
        #{campaignId,jdbcType=BIGINT},
      </if>
      <if test="withdrawableDate != null">
        #{withdrawableDate,jdbcType=TIMESTAMP},
      </if>
      <if test="withdrawedId != null">
        #{withdrawedId,jdbcType=BIGINT},
      </if>
      <if test="fortunePayedId != null">
        #{fortunePayedId,jdbcType=BIGINT},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.customer.CustomerFortune">
    update ag_acl_customer_fortune
    <set>
      <if test="shareId != null">
        share_id = #{shareId,jdbcType=BIGINT},
      </if>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=BIGINT},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="orderDate != null">
        order_date = #{orderDate,jdbcType=TIMESTAMP},
      </if>
      <if test="orderPrice != null">
        order_price = #{orderPrice,jdbcType=DECIMAL},
      </if>
      <if test="referralRate != null">
        referral_rate = #{referralRate,jdbcType=DECIMAL},
      </if>
      <if test="referralAmount != null">
        referral_amount = #{referralAmount,jdbcType=DECIMAL},
      </if>
      <if test="isTax != null">
        is_tax = #{isTax,jdbcType=INTEGER},
      </if>
      <if test="taxAmount != null">
        tax_amount = #{taxAmount,jdbcType=DECIMAL},
      </if>
      <if test="netAmount != null">
        net_amount = #{netAmount,jdbcType=DECIMAL},
      </if>
      <if test="campaignId != null">
        campaign_id = #{campaignId,jdbcType=BIGINT},
      </if>
      <if test="withdrawableDate != null">
        withdrawable_date = #{withdrawableDate,jdbcType=TIMESTAMP},
      </if>
      <if test="withdrawedId != null">
        withdrawed_id = #{withdrawedId,jdbcType=BIGINT},
      </if>
      <if test="fortunePayedId != null">
        fortune_payed_id = #{fortunePayedId,jdbcType=BIGINT},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.customer.CustomerFortune">
    update ag_acl_customer_fortune
    set share_id = #{shareId,jdbcType=BIGINT},
      customer_id = #{customerId,jdbcType=BIGINT},
      order_id = #{orderId,jdbcType=BIGINT},
      order_date = #{orderDate,jdbcType=TIMESTAMP},
      order_price = #{orderPrice,jdbcType=DECIMAL},
      referral_rate = #{referralRate,jdbcType=DECIMAL},
      referral_amount = #{referralAmount,jdbcType=DECIMAL},
      is_tax = #{isTax,jdbcType=INTEGER},
      tax_amount = #{taxAmount,jdbcType=DECIMAL},
      net_amount = #{netAmount,jdbcType=DECIMAL},
      campaign_id = #{campaignId,jdbcType=BIGINT},
      withdrawable_date = #{withdrawableDate,jdbcType=TIMESTAMP},
      withdrawed_id = #{withdrawedId,jdbcType=BIGINT},
      fortune_payed_id = #{fortunePayedId,jdbcType=BIGINT},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>