from tab_haoban_open_staff a left JOIN tab_haoban_staff b on a.staff_id = b.staff_id
where a.wx_enterprise_id = #{wxEnterpriseId} and a.enterprise_id=#{enterpriseId}
<iftest="status==1">
and a.status_flag = 1
</if>
<iftest="status==2">
and a.status_flag = 2 and a.first_auth_time is not null
</if>
<iftest="status==3">
and a.status_flag = 2 and a.valid_qrcode_flag = 1
</if>
<iftest="status==4">
and a.status_flag = 2 and a.first_auth_time is null
</if>
<iftest="staffParams != null and staffParams != ''">
and (b.staff_name like CONCAT('%',#{staffParams},'%') or b.wx_user_id like CONCAT('%',#{staffParams},'%') or b.wx_open_user_id like CONCAT('%',#{staffParams},'%') )
select wx_enterprise_id wxEnterpriseId , staff_id staffId FROM tab_haoban_group_chat WHERE update_time > DATE_ADD(NOW(),INTERVAL -7 DAY) AND chat_status = 1 and staff_id is not null
select wx_enterprise_id wxEnterpriseId , staff_id staffId FROM tab_haoban_group_chat WHERE update_time > DATE_ADD(NOW(),INTERVAL -7 DAY) AND chat_status = 1 and staff_id is not null
select wx_chat_id_dk from tab_haoban_group_chat where enterprise_id=#{enterpriseId} and staff_id = #{staffId} and delete_flag=0 and chat_status != 4 and wx_chat_id_dk is not null