<?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="cn.superdesk.uniorder.dao.mapper.order.BankRecordMapper">
	<resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.order.BankRecord">
		<id column="sn" property="sn" jdbcType="VARCHAR"/>
		<result column="bank_name" property="bankName" jdbcType="VARCHAR"/>
		<result column="rec_date" property="recDate" jdbcType="TIMESTAMP"/>
		<result column="rec_amount" property="recAmount" jdbcType="DECIMAL"/>
		<result column="remarks" property="remarks" jdbcType="VARCHAR"/>
		<result column="pay_name" property="payName" jdbcType="VARCHAR"/>
		<result column="bank_no" property="bankNo" jdbcType="VARCHAR"/>
		<result column="off_status" property="offStatus" jdbcType="TINYINT"/>
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
		<result column="create_user_id" property="createUserId" jdbcType="BIGINT"/>
	</resultMap>
	<select id="findBank" resultType="java.lang.String">
  	select DISTINCT(bank_name) from bank_record 
    </select>
	<select id="findAll" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List"/>
		from bank_record where 1=1
		<if test="startTime != null and startTime != ''">
			and DATE_FORMAT(rec_date,'%Y-%m-%d %H:%i:%s') &gt;= #{startTime,jdbcType=VARCHAR}
		</if>
		<if test="endTime != null and endTime != ''">
			and DATE_FORMAT(rec_date,'%Y-%m-%d %H:%i:%s') &lt;= #{endTime,jdbcType=VARCHAR}
		</if>
		<if test="sn != null and sn != '' ">
			and sn like CONCAT('%',#{sn,jdbcType=VARCHAR},'%')
		</if>
		<if test="bankNo != null and bankNo != '' ">
			and bank_no like CONCAT('%',#{bankNo,jdbcType=VARCHAR},'%')
		</if>
		<if test="payName != null and payName != '' ">
			and pay_name like CONCAT('%',#{payName,jdbcType=VARCHAR},'%')
		</if>
		<if test="bankName != null and bankName != '' ">
			and bank_name = #{bankName,jdbcType=VARCHAR}
		</if>
		<if test="offStatus != null and offStatus != '' ">
			and off_status = #{offStatus,jdbcType=TINYINT}
		</if>
		order by create_time desc
	</select>

	<sql id="Base_Column_List">
    sn, bank_name, rec_date, rec_amount, remarks, pay_name, bank_no, off_status, create_time, 
    create_user_id
  </sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
		select
		<include refid="Base_Column_List"/>
		from bank_record
		where sn = #{sn,jdbcType=VARCHAR}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from bank_record
    where sn = #{sn,jdbcType=VARCHAR}
  </delete>
	<insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.order.BankRecord">
    insert into bank_record (sn, bank_name, rec_date, 
      rec_amount, remarks, pay_name, 
      bank_no, off_status, create_time, 
      create_user_id)
    values (#{sn,jdbcType=VARCHAR}, #{bankName,jdbcType=VARCHAR}, #{recDate,jdbcType=TIMESTAMP}, 
      #{recAmount,jdbcType=DECIMAL}, #{remarks,jdbcType=VARCHAR}, #{payName,jdbcType=VARCHAR}, 
      #{bankNo,jdbcType=VARCHAR}, #{offStatus,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, 
      #{createUserId,jdbcType=BIGINT})
  </insert>
	<insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.order.BankRecord">
		insert into bank_record
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="sn != null">
				sn,
			</if>
			<if test="bankName != null">
				bank_name,
			</if>
			<if test="recDate != null">
				rec_date,
			</if>
			<if test="recAmount != null">
				rec_amount,
			</if>
			<if test="remarks != null">
				remarks,
			</if>
			<if test="payName != null">
				pay_name,
			</if>
			<if test="bankNo != null">
				bank_no,
			</if>
			<if test="offStatus != null">
				off_status,
			</if>
			<if test="createTime != null">
				create_time,
			</if>
			<if test="createUserId != null">
				create_user_id,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="sn != null">
				#{sn,jdbcType=VARCHAR},
			</if>
			<if test="bankName != null">
				#{bankName,jdbcType=VARCHAR},
			</if>
			<if test="recDate != null">
				#{recDate,jdbcType=TIMESTAMP},
			</if>
			<if test="recAmount != null">
				#{recAmount,jdbcType=DECIMAL},
			</if>
			<if test="remarks != null">
				#{remarks,jdbcType=VARCHAR},
			</if>
			<if test="payName != null">
				#{payName,jdbcType=VARCHAR},
			</if>
			<if test="bankNo != null">
				#{bankNo,jdbcType=VARCHAR},
			</if>
			<if test="offStatus != null">
				#{offStatus,jdbcType=TINYINT},
			</if>
			<if test="createTime != null">
				#{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="createUserId != null">
				#{createUserId,jdbcType=BIGINT},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.order.BankRecord">
		update bank_record
		<set>
			<if test="bankName != null">
				bank_name = #{bankName,jdbcType=VARCHAR},
			</if>
			<if test="recDate != null">
				rec_date = #{recDate,jdbcType=TIMESTAMP},
			</if>
			<if test="recAmount != null">
				rec_amount = #{recAmount,jdbcType=DECIMAL},
			</if>
			<if test="remarks != null">
				remarks = #{remarks,jdbcType=VARCHAR},
			</if>
			<if test="payName != null">
				pay_name = #{payName,jdbcType=VARCHAR},
			</if>
			<if test="bankNo != null">
				bank_no = #{bankNo,jdbcType=VARCHAR},
			</if>
			<if test="offStatus != null">
				off_status = #{offStatus,jdbcType=TINYINT},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=TIMESTAMP},
			</if>
			<if test="createUserId != null">
				create_user_id = #{createUserId,jdbcType=BIGINT},
			</if>
		</set>
		where sn = #{sn,jdbcType=VARCHAR}
	</update>
	<update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.order.BankRecord">
    update bank_record
    set bank_name = #{bankName,jdbcType=VARCHAR},
      rec_date = #{recDate,jdbcType=TIMESTAMP},
      rec_amount = #{recAmount,jdbcType=DECIMAL},
      remarks = #{remarks,jdbcType=VARCHAR},
      pay_name = #{payName,jdbcType=VARCHAR},
      bank_no = #{bankNo,jdbcType=VARCHAR},
      off_status = #{offStatus,jdbcType=TINYINT},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT}
    where sn = #{sn,jdbcType=VARCHAR}
  </update>
</mapper>