<?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.yunniu.farming.webadmin.dao.GroupBuyDao">


	<select id="findPageList" resultType="com.yunniu.farming.webadmin.model.GroupBuy">
		select *,
		(select min(product_price) from group_buy_product where group_buy_id = a.id) minPrice,
		(select max(product_price) from group_buy_product where group_buy_id = a.id) maxPrice
		from group_buy a
		<where>
			<if test="groupBuyCode != null and groupBuycode != ''">
				and group_buy_code = #{groupBuyCode,jdbcType=VARCHAR}
			</if>
			<if test="groupBuyTitle != null and groupBuyTitle != ''">
				and group_buy_title like concat('%', #{groupBuyTitle,jdbcType=VARCHAR},'%')
			</if>
			<if test="appFlag != null and appFlag = ''">
				and group_status = 3
			</if>
		</where>
		order by create_time desc
	</select>

	<update id="updateEndTime">
        update group_buy
        set end_time = #{endTime,jdbcType=TIMESTAMP}
        where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>