<?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.jkcredit.invoice.mapper.customer.CustomerRechargeMapper" >
  <resultMap id="BaseResultMap" type="com.jkcredit.invoice.model.entity.CustomerRecharge" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="customer_name" property="customerName" jdbcType="VARCHAR" />
    <result column="companyName" property="companyName" jdbcType="VARCHAR" />
    <result column="before_money" property="beforeMony" jdbcType="DOUBLE" />
    <result column="recharge_mony" property="rechargeMony" jdbcType="DOUBLE" />
    <result column="recharge_time" property="rechargeTime" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, customer_name,companyName, before_money, recharge_mony, recharge_time
  </sql>
  <select id="selectAllByPage" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_customer_recharge
    <where>
      <if test="customerRecharge.customerName != null and customerRecharge.customerName != ''">
        and  customer_name = BINARY #{customerRecharge.customerName}
      </if>
      <if test="customerRecharge.companyName != null and customerRecharge.companyName != ''">
        and  companyName LIKE BINARY CONCAT('%',#{customerRecharge.companyName},'%')
      </if>
      <if test="customerRecharge.rechargeMony != null and customerRecharge.rechargeMony != ''">
        and recharge_mony = #{rechargeMony,jdbcType=DOUBLE}
      </if>
    </where>
    order by recharge_time desc
  </select>


  <select id="selectAllByPageMoney" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_customer_recharge
    <where>
      1 = 1
      <if test="customerRecharge.customerName != null and customerRecharge.customerName != ''">
        and  customer_name = BINARY #{customerRecharge.customerName}
      </if>
      <if test="customerRecharge.companyName != null and customerRecharge.companyName != ''">
        and  companyName LIKE BINARY CONCAT('%',#{customerRecharge.companyName},'%')
      </if>
      <if test="customerRecharge.rechargeMony != null and customerRecharge.rechargeMony != ''">
        and recharge_mony = #{rechargeMony,jdbcType=DOUBLE}
      </if>
      and  recharge_mony <![CDATA[ > ]]> 0
    </where>
    order by recharge_time desc
  </select>


  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_customer_recharge
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from t_customer_recharge
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.CustomerRecharge" >
    insert into t_customer_recharge ( customer_name,companyName, before_money,recharge_mony,
      recharge_time)
    values ( #{customerName,jdbcType=VARCHAR}, #{companyName,jdbcType=VARCHAR}, #{beforeMony,jdbcType=DOUBLE}, #{rechargeMony,jdbcType=DOUBLE},
      #{rechargeTime,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.jkcredit.invoice.model.entity.CustomerRecharge" >
    insert into t_customer_recharge
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="customerName != null" >
        customer_name,
      </if>
      <if test="companyName != null" >
        companyName,
      </if>
      <if test="beforeMony != null" >
        before_money,
      </if>
      <if test="rechargeMony != null" >
        recharge_mony,
      </if>
      <if test="rechargeTime != null" >
        recharge_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="customerName != null" >
        #{customerName,jdbcType=VARCHAR},
      </if>
      <if test="companyName != null" >
        #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="beforeMony != null" >
        #{before_money,jdbcType=DOUBLE},
      </if>
      <if test="rechargeMony != null" >
        #{rechargeMony,jdbcType=DOUBLE},
      </if>
      <if test="rechargeTime != null" >
        #{rechargeTime,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.jkcredit.invoice.model.entity.CustomerRecharge" >
    update t_customer_recharge
    <set >
      <if test="customerName != null" >
        customer_name = #{customerName,jdbcType=VARCHAR},
      </if>
      <if test="companyName != null" >
        companyName = #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="beforeMony != null" >
        before_money = #{beforeMony,jdbcType=DOUBLE},
      </if>
      <if test="rechargeMony != null" >
        recharge_mony = #{rechargeMony,jdbcType=DOUBLE},
      </if>
      <if test="rechargeTime != null" >
        recharge_time = #{rechargeTime,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.jkcredit.invoice.model.entity.CustomerRecharge" >
    update t_customer_recharge
    set customer_name = #{customerName,jdbcType=VARCHAR},
    companyName = #{companyName,jdbcType=VARCHAR},
      before_money = #{beforeMony,jdbcType=DOUBLE},
      recharge_mony = #{rechargeMony,jdbcType=DOUBLE},
      recharge_time = #{rechargeTime,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>