select t.* from pmn_activity_instance t where 1 =1
select t.*,t1.store_count,t2.abbreviation as store_name,t3.company_count,t4.name as company_name
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 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 privilage_organizational t4 on t4.id=t1.org_id
where 1 =1
<iftest="storeId != null">
<iftest="storeId != null">
and t.id in (select instance_id from pmn_activity_store_relation where
and t.id in (select instance_id from pmn_activity_store_relation where
store_id=#{storeId}
store_id=#{storeId}
@ -51,21 +61,26 @@ select * from pmn_activity_promotion_param where id in(select param_id from pmn_
</foreach>
</foreach>
)
)
</if>
</if>
<iftest="organizationId != null and organizationId != ''">
and t.id in (select instance_id from pmn_activity_store_relation where