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},'%') )