<?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="lingtao.net.dao.CustomerAwardMapper">

  	<!-- 查询列表 -->
	<select id="getCustomerAward" parameterType="CustomerAward" resultType="CustomerAward">
		select * from tbl_customer_award
		<where>
			<if test="nickname !=null and nickname != '' ">
				and nickname like '%${nickname}%'
			</if>
			<if test="shopname !=null and shopname != '' ">
				and shopname like '%${shopname}%'
			</if>
			<if test="creator !=null and creator != '' ">
				and creator like '%${creator}%'
			</if>
			<if test="createTimeBegin !=null and createTimeBegin != '' ">
				<![CDATA[and awardDate >= #{createTimeBegin} ]]>
			</if>
			<if test="createTimeEnd !=null and createTimeEnd != '' ">
				<![CDATA[and awardDate <= #{createTimeEnd} ]]>
			</if>
		</where>
		order by createDate DESC
	</select>
	
	<!-- 批量删除数据 -->
  	<delete id="deleteBatch" parameterType="int">
		<!-- delete from tbl_finance where financeId in(7789,7790) -->
		<!-- forEach:用来循环; collection:用来指定循环的数据的类型; 可以填的值有：array,list,map 
			 item:循环中为每个循环的数据指定一个别名; index:循环中循环的下标 ; open:开始; close:结束; separator:数组中元素之间的分隔符 -->
		delete from tbl_customer_award where id in
		<foreach collection="array" item="id" open="(" separator="," close=")">
			#{id}
		</foreach>
  	</delete>
  	
  	<!-- 批量插入 -->
  	<insert id="insertForeach" parameterType="java.util.List">
	    insert into tbl_customer_award (
	      id, nickname, payPercent, askNumber, customerPrice,award,shopname,awardDate,creator,createDate)
	    values 
	    <foreach collection="list" item="item" index="index" separator=",">
	     (
	      null,#{item.nickname},#{item.payPercent},#{item.askNumber},#{item.customerPrice},#{item.award},#{item.shopname},#{item.awardDate},#{item.creator},now())
	    </foreach>		
  	</insert>
</mapper>