huanghongfa
2021-01-11 0273c333ed5c86822be1f56623e3e6bab90ec2f7
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActActivityDAO.java
@@ -9,6 +9,7 @@
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
@@ -92,4 +93,36 @@
    @Select("select t.activity_name,t.id,t.end_at,t.cover,t.status from com_act_act_sign s  join sys_user u on s.user_id=u.user_id and u.phone=#{phone} and s.is_volunteer=1 " +
            "join com_act_activity t on s.activity_id=t.id and t.status=5")
    List<ComActActivityVO> listActivityByPhone(String phone);
    @Select("select t.id from (\n" +
            "SELECT \n" +
            "a.id,\n" +
            "a.activity_name,\n" +
            "COUNT(case when s.is_volunteer=1 then s.id else null end )volunteernum,\n" +
            "COUNT(case when s.is_volunteer=0 then s.id else null end)usernum,\n" +
            "a.participant_min,\n" +
            "a.volunteer_min\n" +
            "FROM\n" +
            "com_act_activity a \n" +
            "LEFT JOIN com_act_act_sign s on a.id=s.activity_id \n" +
            "WHERE\n" +
            "a.`status` in(3,4) and DATEDIFF(SYSDATE(),a.sign_up_end)>=0\n" +
            "GROUP BY a.id)t WHERE t.usernum<participant_min or t.volunteernum<volunteer_min")
    List<Long> selectTimedTaskActActivity();
    @Update("<script> " +
       "update com_act_activity set `status`=6 where id in\n" +
            "<foreach item=\"item\" collection=\"longs\" separator=\",\" open=\"(\" close=\")\" index=\"\">\n"+
            "#{item}\n"+
            "</foreach>\n"+
        "</script>")
    int updateIdBatch(@Param("longs") List<Long> longs);
    @Update("update com_act_activity set `status`=2 where `status`=1 and DATEDIFF(SYSDATE(),publish_at)>=0")
    int updateStatusToNotBegin();
    @Update("update com_act_activity set `status`=3 where `status`=2 and DATEDIFF(SYSDATE(),sign_up_begin)>=0")
    int updateStatusToBeginSign();
    @Update("update com_act_activity set `status`=(if(DATEDIFF(SYSDATE(),end_at)>=0,5,4)) where `status`=3 and DATEDIFF(SYSDATE(),begin_at)>=0")
    int updateStatusToBeginActiveOrEnd();
}