<?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.AclCustomerFortuneStatisticMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclCustomerFortuneStatistic">
    <!--@mbg.generated-->
    <!--@Table ag_acl_customer_fortune_statistic-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="accumulated_fortune" jdbcType="DECIMAL" property="accumulatedFortune" />
    <result column="drawn_fortune" jdbcType="DECIMAL" property="drawnFortune" />
    <result column="cancelled_fortune" jdbcType="DECIMAL" property="cancelledFortune" />
    <result column="remark" jdbcType="LONGVARCHAR" property="remark" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, customer_id, accumulated_fortune, drawn_fortune, cancelled_fortune, remark, created_at, 
    created_by, updated_at, updated_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from ag_acl_customer_fortune_statistic
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ag_acl_customer_fortune_statistic
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclCustomerFortuneStatistic" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_customer_fortune_statistic (customer_id, accumulated_fortune, drawn_fortune, 
      cancelled_fortune, remark, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{customerId,jdbcType=BIGINT}, #{accumulatedFortune,jdbcType=DECIMAL}, #{drawnFortune,jdbcType=DECIMAL}, 
      #{cancelledFortune,jdbcType=DECIMAL}, #{remark,jdbcType=LONGVARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclCustomerFortuneStatistic" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_customer_fortune_statistic
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="accumulatedFortune != null">
        accumulated_fortune,
      </if>
      <if test="drawnFortune != null">
        drawn_fortune,
      </if>
      <if test="cancelledFortune != null">
        cancelled_fortune,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        #{customerId,jdbcType=BIGINT},
      </if>
      <if test="accumulatedFortune != null">
        #{accumulatedFortune,jdbcType=DECIMAL},
      </if>
      <if test="drawnFortune != null">
        #{drawnFortune,jdbcType=DECIMAL},
      </if>
      <if test="cancelledFortune != null">
        #{cancelledFortune,jdbcType=DECIMAL},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=LONGVARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.customer.AclCustomerFortuneStatistic">
    <!--@mbg.generated-->
    update ag_acl_customer_fortune_statistic
    <set>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=BIGINT},
      </if>
      <if test="accumulatedFortune != null">
        accumulated_fortune = #{accumulatedFortune,jdbcType=DECIMAL},
      </if>
      <if test="drawnFortune != null">
        drawn_fortune = #{drawnFortune,jdbcType=DECIMAL},
      </if>
      <if test="cancelledFortune != null">
        cancelled_fortune = #{cancelledFortune,jdbcType=DECIMAL},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=LONGVARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.customer.AclCustomerFortuneStatistic">
    <!--@mbg.generated-->
    update ag_acl_customer_fortune_statistic
    set customer_id = #{customerId,jdbcType=BIGINT},
      accumulated_fortune = #{accumulatedFortune,jdbcType=DECIMAL},
      drawn_fortune = #{drawnFortune,jdbcType=DECIMAL},
      cancelled_fortune = #{cancelledFortune,jdbcType=DECIMAL},
      remark = #{remark,jdbcType=LONGVARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_acl_customer_fortune_statistic
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="customer_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.customerId,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="accumulated_fortune = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.accumulatedFortune,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="drawn_fortune = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.drawnFortune,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="cancelled_fortune = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.cancelledFortune,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.remark,jdbcType=LONGVARCHAR}
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_acl_customer_fortune_statistic
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="customer_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.customerId != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.customerId,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="accumulated_fortune = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.accumulatedFortune != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.accumulatedFortune,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="drawn_fortune = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.drawnFortune != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.drawnFortune,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="cancelled_fortune = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.cancelledFortune != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.cancelledFortune,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.remark != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.remark,jdbcType=LONGVARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_acl_customer_fortune_statistic
    (customer_id, accumulated_fortune, drawn_fortune, cancelled_fortune, remark, created_at, 
      created_by, updated_at, updated_by)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.customerId,jdbcType=BIGINT}, #{item.accumulatedFortune,jdbcType=DECIMAL}, 
        #{item.drawnFortune,jdbcType=DECIMAL}, #{item.cancelledFortune,jdbcType=DECIMAL}, 
        #{item.remark,jdbcType=LONGVARCHAR}, #{item.createdAt,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=BIGINT}, 
        #{item.updatedAt,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=BIGINT})
    </foreach>
  </insert>

  <select id="findByCustomerIds" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_acl_customer_fortune_statistic
    where customer_id in
    <foreach collection="array" item="item" open="(" separator="," close=")">
      #{item,jdbcType=BIGINT}
    </foreach>
    </select>

  <select id="findByCustomerId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_acl_customer_fortune_statistic
    where customer_id = #{customerId,jdbcType=BIGINT}
    </select>
</mapper>