<?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.pluss.platform.mapper.ActivityRecommendMapper">

	   	<insert id="saveActivityRecommend" parameterType="cn.pluss.platform.entity.ActivityRecommend">
        	insert into tb_pluss_activity_recommend(userId,name,firstMixRechargeMoney,recommendMoney,merchantCode,merchantName,storeId,storeName,createDt)VALUES(#{userId},#{name},#{firstMixRechargeMoney},#{recommendMoney},#{merchantCode},#{merchantName},#{storeId},#{storeName},NOW())
    	</insert>

	   	<insert id="saveActivityRecommendBatch">
        	insert into tb_pluss_activity_recommend(userId,name,firstMixRechargeMoney,recommendMoney,merchantCode,merchantName,storeId,storeName,createDt) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{userId},#{name},#{firstMixRechargeMoney},#{recommendMoney},#{merchantCode},#{merchantName},#{storeId},#{storeName},#{createDt}		)
				</foreach>
    	</insert>

		<select id="queryActivityRecommend" parameterType="cn.pluss.platform.entity.ActivityRecommend" resultType="cn.pluss.platform.entity.ActivityRecommend">
			SELECT * from tb_pluss_activity_recommend 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </if> 
					<if test="userId!= null"> 
					 	and userId = #{userId}
					 </if> 
					<if test="name!= null"> 
					 	and name = #{name}
					 </if> 
					<if test="firstMixRechargeMoney!= null"> 
					 	and firstMixRechargeMoney = #{firstMixRechargeMoney}
					 </if> 
					<if test="recommendMoney!= null"> 
					 	and recommendMoney = #{recommendMoney}
					 </if> 
					<if test="merchantCode!= null"> 
					 	and merchantCode = #{merchantCode}
					 </if> 
					<if test="merchantName!= null"> 
					 	and merchantName = #{merchantName}
					 </if> 
					<if test="storeId!= null"> 
					 	and storeId = #{storeId}
					 </if> 
					<if test="storeName!= null"> 
					 	and storeName = #{storeName}
					 </if> 
					<if test="createDt!= null"> 
					 	and createDt = #{createDt}
					 </if> 
				 </where> 
		</select>

		<select id="queryActivityRecommendList" parameterType="cn.pluss.platform.entity.ActivityRecommend" resultType="cn.pluss.platform.entity.ActivityRecommend">
			SELECT * from tb_pluss_activity_recommend 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </if> 
					<if test="userId!= null"> 
					 and 	userId = #{userId}
					 </if> 
					<if test="name!= null"> 
					 and 	name = #{name}
					 </if> 
					<if test="firstMixRechargeMoney!= null"> 
					 and 	firstMixRechargeMoney = #{firstMixRechargeMoney}
					 </if> 
					<if test="recommendMoney!= null"> 
					 and 	recommendMoney = #{recommendMoney}
					 </if> 
					<if test="merchantCode!= null"> 
					 and 	merchantCode = #{merchantCode}
					 </if> 
					<if test="merchantName!= null"> 
					 and 	merchantName = #{merchantName}
					 </if> 
					<if test="storeId!= null"> 
					 and 	storeId = #{storeId}
					 </if> 
					<if test="storeName!= null"> 
					 and 	storeName = #{storeName}
					 </if> 
					<if test="createDt!= null"> 
					 and 	createDt = #{createDt}
					 </if> 
				 </where> 
		</select>

		<update id="updateActivityRecommend" parameterType="cn.pluss.platform.entity.ActivityRecommend" >
			update tb_pluss_activity_recommend 
				  <set> 
					<if test="userId!= null"> 
					 	userId = #{userId},
					 </if> 
					<if test="name!= null"> 
					 	name = #{name},
					 </if> 
					<if test="firstMixRechargeMoney!= null"> 
					 	firstMixRechargeMoney = #{firstMixRechargeMoney},
					 </if> 
					<if test="recommendMoney!= null"> 
					 	recommendMoney = #{recommendMoney},
					 </if> 
					<if test="merchantCode!= null"> 
					 	merchantCode = #{merchantCode},
					 </if> 
					<if test="merchantName!= null"> 
					 	merchantName = #{merchantName},
					 </if> 
					<if test="storeId!= null"> 
					 	storeId = #{storeId},
					 </if> 
					<if test="storeName!= null"> 
					 	storeName = #{storeName},
					 </if> 
					<if test="createDt!= null"> 
					 	createDt = #{createDt}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteActivityRecommend" parameterType="cn.pluss.platform.entity.ActivityRecommend" >
			DELETE FROM tb_pluss_activity_recommend where id=#{id}
		</delete>

		<select id="queryActivityRecommendPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.ActivityRecommend">
			SELECT * from tb_pluss_activity_recommend 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </if> 
					<if test="userId!= null"> 
					and userId = #{userId}
					 </if> 
					<if test="name!= null"> 
					and name like CONCAT("%",#{name},"%")
					 </if> 
					<if test="firstMixRechargeMoney!= null"> 
					and firstMixRechargeMoney = #{firstMixRechargeMoney}
					 </if> 
					<if test="recommendMoney!= null"> 
					and recommendMoney = #{recommendMoney}
					 </if> 
					<if test="merchantCode!= null"> 
					and merchantCode = #{merchantCode}
					 </if> 
					<if test="merchantName!= null"> 
					and merchantName = #{merchantName}
					 </if> 
					<if test="storeId!= null"> 
					and storeId = #{storeId}
					 </if> 
					<if test="storeName!= null"> 
					and storeName = #{storeName}
					 </if> 
					<if test="createDt!= null"> 
					and createDt = #{createDt}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryActivityRecommendPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_activity_recommend 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </if> 
					<if test="userId!= null"> 
					 and userId = #{userId}
					 </if> 
					<if test="name!= null"> 
					 and name like CONCAT("%",#{name},"%")
					 </if> 
					<if test="firstMixRechargeMoney!= null"> 
					 and firstMixRechargeMoney = #{firstMixRechargeMoney}
					 </if> 
					<if test="recommendMoney!= null"> 
					 and recommendMoney = #{recommendMoney}
					 </if> 
					<if test="merchantCode!= null"> 
					 and merchantCode = #{merchantCode}
					 </if> 
					<if test="merchantName!= null"> 
					 and merchantName = #{merchantName}
					 </if> 
					<if test="storeId!= null"> 
					 and storeId = #{storeId}
					 </if> 
					<if test="storeName!= null"> 
					 and storeName = #{storeName}
					 </if> 
					<if test="createDt!= null"> 
					 and createDt = #{createDt}
					 </if> 
				</where>
		</select>

</mapper>
