<?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.huiju.estateagents.mapper.TaShareActivityMapper">
    <select id="selectTaShareActivityById" resultType="com.huiju.estateagents.entity.TaShareActivity">
        select
        t.group_activity_id,
        t.building_id,
        t.activity_name,
        t.main_img,
        t.group_buy_people,
        t.integral,
        t.share_id,
        t.poster_id,
        t.status
        from ta_share_activity t where t.group_activity_id = #{activityId}
    </select>

    <update id="updateActivityToUnStart">
      update ta_share_activity
      set activity_status = 1
      where
      NOW() &lt; start_time and activity_status != 2
    </update>

    <update id="updateUnStartGroupActivity">
        update ta_share_activity t
        set activity_status = 0
        where
        t.activity_status != '2' and NOW() BETWEEN t.start_time and t.end_time
    </update>

    <update id="updateProcessGroupActivity">
        update ta_share_activity
        set activity_status = 2
        where
	    NOW() > end_time and activity_status  != 2
    </update>

    <select id="calParticipateNum" resultType="java.lang.Integer">
        select t.join_people as num from ta_share_record t where t.group_activity_id = #{groupActivityId} group by t.group_activity_id
    </select>

</mapper>
