<?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.tangguo.mapper.BbsUserPointsExchangeMapper">
	
	<select id="selectBbsUserPointsExchangeList" resultType="com.tangguo.domain.BbsUserPointsExchange">
		SELECT
			e.*
		FROM
			bbs_user_points_exchange e
		<where>
			<if test="exchange.nickName != null and exchange.nickName != ''">
				e.nick_name LIKE CONCAT('%', #{exchange.nickName}, '%')
			</if>
			<if test="exchange.userName != null and exchange.userName != ''">
				AND e.user_name LIKE CONCAT('%', #{exchange.userName}, '%')
			</if>
			<if test="exchange.goodsName != null and exchange.goodsName != ''">
				AND e.goods_name LIKE CONCAT('%', #{exchange.goodsName}, '%')
			</if>
			<if test="exchange.goodsCode != null and exchange.goodsCode != ''">
				AND e.goods_code LIKE CONCAT('%', #{exchange.goodsCode}, '%')
			</if>
			<if test="exchange.params.startTime != null and exchange.params.startTime != ''">
				AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{exchange.params.startTime}
			</if>
			<if test="exchange.params.endTime != null and exchange.params.endTime != ''">
				AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{exchange.params.endTime}
			</if>
		</where>
		ORDER BY
			e.create_time DESC
	</select>
	
</mapper>
