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

    <update id="updateEndGroupActivity">
        update ta_share_child_record a
        LEFT JOIN ta_share_activity b on a.group_activity_id = b.group_activity_id
        set a.`status` = '2'
        where (NOW() > b.end_time or b.activity_status = '2') and a.`status` = '1' and a.status != '0'
    </update>

    <update id="updateActivityProcessToEndByGroupActivityId">
      <if test="groupActivityId != null and groupActivityId != ''">
          update ta_share_child_record a set a.status = '2' where a.group_activity_id = #{groupActivityId} and a.status != 0
      </if>
    </update>

    <select id="getList" resultType="com.huiju.estateagents.entity.TaShareChildRecord">
        select
          t.nickname,
          t.phone,
          t.create_time
        from ta_share_child_record t
        where 1=1
        <if test="orgId != null and orgId != ''">
            and t.org_id = #{orgId}
        </if>
        <if test="status != null and status != ''">
            and t.status = #{status}
        </if>
        <if test="groupActivityId != null and groupActivityId != ''">
            and t.group_Activity_Id = #{groupActivityId}
        </if>
        <if test="recordId != null and recordId != ''">
            and t.record_id = #{recordId}
        </if>
    </select>
    <select id="getShareRecordExportList" resultType="com.huiju.estateagents.excel.ShareChildRecordExport">
        select
        t.nickname,
        t.phone,
        t.create_time
        from ta_share_child_record t
        where 1=1
        <if test="status != null and status != ''">
            and t.status = #{status}
        </if>
        <if test="recordId != null and recordId != ''">
            and t.record_id = #{recordId}
        </if>
        <if test="groupActivityId != null and groupActivityId != ''">
            and t.group_Activity_Id = #{groupActivityId}
        </if>
        limit #{pageCode}, #{pageSize}
    </select>
</mapper>
