`id`,`tenant_id`,`parent_tenant_id`,`topic_type`,`name`,`title`,`content`,`cover`,`cover_picture`,`detail_picture`,`advert`,`begin_time`,`end_time`,`is_only_ad`,`createtime`,`updatetime`,`bg_color`
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and `topic_type` = #{topicType}
and `begin_time` >= #{beginTime}
and `begin_time` <= #{endTime}
and `end_time` >= #{beginTime}
and `end_time` <= #{endTime}
and `status` = #{status}
and `name` like concat('%',#{name},'%')
and status in
#{statusItem}
order by ${sortColumns}order by begin_time desc,status asc
update wx_topic set status = 3 where id in(
select t.id from (
select id from wx_topic where `topic_type` = 1 and status !=3 and now() >= end_time and tenant_id = #{tenantId}
) t
)
update wx_coupon_channel set status = 1 where status = 0 and target_ad = 8 and sub_target_id in(
select id from wx_topic where `topic_type` = 1 and status in(2,3) and tenant_id = #{tenantId}
)