<?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.MemberSettingMapper">

	   	<insert id="saveMemberSetting" parameterType="cn.pluss.platform.entity.MemberSetting">
        	insert into tb_pluss_member_setting(merchantCode,merchantName,storeId,storeName,servicePhone,cardNum,cardContent,createDt,payDt,staffName)VALUES(#{merchantCode},#{merchantName},#{storeId},#{storeName},#{servicePhone},#{cardNum},#{cardContent},#{createDt},#{payDt},#{staffName})
    	</insert>

	   	<insert id="saveMemberSettingBatch">
        	insert into tb_pluss_member_setting(merchantCode,merchantName,storeId,storeName,servicePhone,cardNum,cardContent,createDt,payDt,staffName) VALUES 
    			<foreach collection="list" item="item" index="index" separator=",">
			(#{merchantCode},#{merchantName},#{storeId},#{storeName},#{servicePhone},#{cardNum},#{cardContent},#{createDt},#{payDt},#{staffName}		)
				</foreach>
    	</insert>

		<select id="queryMemberSetting" parameterType="cn.pluss.platform.entity.MemberSetting" resultType="cn.pluss.platform.entity.MemberSetting">
			SELECT * from tb_pluss_member_setting 
				<where> 
					<if test="id!= null"> 
					 	and id = #{id}
					 </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="servicePhone!= null"> 
					 	and servicePhone = #{servicePhone}
					 </if> 
					<if test="cardNum!= null"> 
					 	and cardNum = #{cardNum}
					 </if> 
					<if test="cardContent!= null"> 
					 	and cardContent = #{cardContent}
					 </if> 
					<if test="createDt!= null"> 
					 	and createDt = #{createDt}
					 </if> 
					<if test="payDt!= null"> 
					 	and payDt = #{payDt}
					 </if> 
					<if test="staffName!= null"> 
					 	and staffName = #{staffName}
					 </if> 
				 </where> 
		</select>

		<select id="queryMemberSettingList" parameterType="cn.pluss.platform.entity.MemberSetting" resultType="cn.pluss.platform.entity.MemberSetting">
			SELECT * from tb_pluss_member_setting 
				<where> 
					<if test="id!= null"> 
					 and 	id = #{id}
					 </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="servicePhone!= null"> 
					 and 	servicePhone = #{servicePhone}
					 </if> 
					<if test="cardNum!= null"> 
					 and 	cardNum = #{cardNum}
					 </if> 
					<if test="cardContent!= null"> 
					 and 	cardContent = #{cardContent}
					 </if> 
					<if test="createDt!= null"> 
					 and 	createDt = #{createDt}
					 </if> 
					<if test="payDt!= null"> 
					 and 	payDt = #{payDt}
					 </if> 
					<if test="staffName!= null"> 
					 and 	staffName = #{staffName}
					 </if> 
				 </where> 
		</select>

		<update id="updateMemberSetting" parameterType="cn.pluss.platform.entity.MemberSetting" >
			update tb_pluss_member_setting 
				  <set> 
					<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="servicePhone!= null"> 
					 	servicePhone = #{servicePhone},
					 </if> 
					<if test="cardNum!= null"> 
					 	cardNum = #{cardNum},
					 </if> 
					<if test="cardContent!= null"> 
					 	cardContent = #{cardContent},
					 </if> 
					<if test="createDt!= null"> 
					 	createDt = #{createDt},
					 </if> 
					<if test="payDt!= null"> 
					 	payDt = #{payDt},
					 </if> 
					<if test="staffName!= null"> 
					 	staffName = #{staffName}
					 </if> 
				</set>
			where id=#{id} 
		</update>

		<delete id="deleteMemberSetting" parameterType="cn.pluss.platform.entity.MemberSetting" >
			DELETE FROM tb_pluss_member_setting where id=#{id}
		</delete>

		<select id="queryMemberSettingPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.MemberSetting">
			SELECT * from tb_pluss_member_setting 
				<where> 
					<if test="id!= null"> 
					and id = #{id}
					 </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="servicePhone!= null"> 
					and servicePhone = #{servicePhone}
					 </if> 
					<if test="cardNum!= null"> 
					and cardNum = #{cardNum}
					 </if> 
					<if test="cardContent!= null"> 
					and cardContent = #{cardContent}
					 </if> 
					<if test="createDt!= null"> 
					and createDt = #{createDt}
					 </if> 
					<if test="payDt!= null"> 
					and payDt = #{payDt}
					 </if> 
					<if test="staffName!= null"> 
					and staffName = #{staffName}
					 </if> 
				 </where> 
			order by id desc  limit #{pageSize}  offset  #{offset}  
		</select>

		<select id="queryMemberSettingPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
			SELECT count(*) from tb_pluss_member_setting 
					<where> 
					<if test="id!= null"> 
					 and id = #{id}
					 </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="servicePhone!= null"> 
					 and servicePhone = #{servicePhone}
					 </if> 
					<if test="cardNum!= null"> 
					 and cardNum = #{cardNum}
					 </if> 
					<if test="cardContent!= null"> 
					 and cardContent = #{cardContent}
					 </if> 
					<if test="createDt!= null"> 
					 and createDt = #{createDt}
					 </if> 
					<if test="payDt!= null"> 
					 and payDt = #{payDt}
					 </if> 
					<if test="staffName!= null"> 
					 and staffName = #{staffName}
					 </if> 
				</where>
		</select>

</mapper>
