select t.*,t1.store_count,t2.abbreviation as store_name,t3.company_count,t4.name as company_name
select t.*,t1.store_count,t2.abbreviation as store_name,t3.company_count,t4.name as company_name
from pmn_activity_instance t
from pmn_activity_instance t
left join (select instance_id, count(1) as store_count,store_id,org_id from pmn_activity_store_relation group by instance_id) t1 on t.id=t1.instance_id
left join (select instance_id, count(1) as store_count,store_id,org_id from pmn_activity_store_relation group by
instance_id) t1 on t.id=t1.instance_id
left join poi_store t2 on t2.id=t1.store_id
left join poi_store t2 on t2.id=t1.store_id
left join (select instance_id, count(DISTINCT org_id) as company_count,store_id from pmn_activity_store_relation group by instance_id) t3 on t.id=t3.instance_id
left join (select instance_id, count(DISTINCT org_id) as company_count,store_id from pmn_activity_store_relation
group by instance_id) t3 on t.id=t3.instance_id
left join privilage_organizational t4 on t4.id=t1.org_id
left join privilage_organizational t4 on t4.id=t1.org_id
where 1 =1
where 1 =1
<iftest="storeId != null">
<iftest="storeId != null">
@ -92,11 +94,10 @@ select * from pmn_activity_promotion_param where id in(select param_id from pmn_
<iftest="status != null">
<iftest="status != null">
and t.status = #{status}
and t.status = #{status}
</if>
</if>
<iftest="startDate != null">
<iftest="startDate != null and endDate != null">
and t.begin_time <![CDATA[ >= ]]> #{startDate}
and ((begin_time >= #{startDate} AND begin_time <![CDATA[ <= ]]> #{endDate})
</if>
OR (begin_time <![CDATA[ <= ]]> #{startDate} AND end_time >= #{endDate})
<iftest="endDate != null">
OR (end_time >= #{startDate} AND end_time <![CDATA[ <= ]]> #{endDate}))