select
            a.id,
            a.address,
            a.index_img,
            a.code,
            a.type,
            a.name,
            a.state,
            (select count(z.id) from happy_follow z where z.source_id = a.id) as join_cnt,
            a.start_time,
            a.end_time
        from happy_activity a
        
            a.state != 0
            and a.DELETE_FLAG = 0
            
                
                    and a.name like CONCAT('%', CONCAT(#{record.query}, '%'))
                 
                
                    and a.hot_state=#{record.hotState}
                 
                
                    and a.category_id=#{record.categoryId}
                 
             
         
        
            order by (select count(y.id) from happy_follow y where y.source_id = a.id and type in (2,3)) desc,a.order_cnt asc
         
        
            order by a.order_cnt asc,a.id desc
         
     
    
        select
            a.member_id as memberId,
                a.created_time as createdTime
        from happy_follow a
        where
            a.type = 4
            and a.source_option_id = #{record.sourceOptionId}
        order by a.id desc
     
    
        update happy_activity_option set likes_cnt = likes_cnt + 1 where id = #{id}
     
    
        update happy_activity set surplus_cnt = surplus_cnt + #{cnt} where id = #{id}
     
    
        select
            a.id as id,
            a.order_cnt as orderCnt,
            a.option_name as optionName,
            a.image as image,
            a.likes_cnt as likesCnt
        from happy_activity_option a
        
            and a.state = 1
            and a.activity_id = #{record.activityId}
            and a.DELETE_FLAG = 0
            
                
                    and (
                    a.option_name like CONCAT('%', CONCAT(#{record.query}, '%'))
                    or
                    a.order_cnt = #{record.query}
                    )
                 
             
         
        order by a.order_cnt asc
     
    
        select
        a.*,
               b.name as name,
               c.name as activityName
        from happy_activity_order a
        left join mall_member b on a.member_id = b.id
        left join happy_activity c on a.activity_id = c.id
        
            and a.DELETE_FLAG = 0
            
                
                    and b.name like CONCAT('%', CONCAT(#{record.name}, '%'))
                 
                
                    and a.state=#{record.state}
                 
                
                    and a.activity_id=#{record.activityId}
                 
             
         
        order by a.id desc
     
    
        select
        a.id as id,
        a.option_name as optionName,
        a.image as image,
        a.likes_cnt as likesCnt
        from happy_activity_option a
        
            and a.state = 1
            and a.activity_id = #{record.activityId}
            and a.DELETE_FLAG = 0
            
                
                    and (
                    a.option_name like CONCAT('%', CONCAT(#{record.query}, '%'))
                    or
                    a.order_cnt = #{record.query}
                    )
                 
             
         
        order by a.likes_cnt desc