/*社保代办理 1.派单审核通过 2.派增(type=0):待办理(social_handle_status='0') or 派减(type=1):已办理完成或部分办理失败 且已派减*/
AND a.social_id is not null
AND a.STATUS = "2"
and (( a.type = '0' AND (s.HANDLE_STATUS = "0" or s.HANDLE_STATUS = "4") ) or ( a.type ='1' AND (if(ifnull(h.id,0) != 0,h.HANDLE_STATUS,s.HANDLE_STATUS) in ('1','5','6','3','7') or (s.HANDLE_STATUS in ('1','5','6','3','7') and s.REDUCE_CAN = '1')) ))
and (( a.type = '0' AND (s.HANDLE_STATUS = "0" or s.HANDLE_STATUS = "4") ) or ( a.type ='1' AND (if(ifnull(h.id,0) != '0',h.HANDLE_STATUS,s.HANDLE_STATUS) in ('1','5','6','3','7') or (s.HANDLE_STATUS in ('1','5','6','3','7') and s.REDUCE_CAN = '1')) ))
and a.SOCIAL_HANDLE_STATUS in ('0','4')
<!--<if test="tDispatchInfo.status != null and tDispatchInfo.status.trim() != ''">
...
...
@@ -1663,12 +1663,12 @@
AND a.TYPE = #{tDispatchInfo.type}
</if>
<iftest="tDispatchInfo.socialProvince != null and tDispatchInfo.socialProvince!= null">
AND if(ifnull(h.id,0) != 0,h.social_province,s.social_province) = #{tDispatchInfo.socialProvince}
AND if(ifnull(h.id,0) != '0',h.social_province,s.social_province) = #{tDispatchInfo.socialProvince}
<iftest="tDispatchInfo.socialCity != null and tDispatchInfo.socialCity!= null">
AND if(ifnull(h.id,0) != 0,h.social_city,s.social_city) = #{tDispatchInfo.socialCity}
AND if(ifnull(h.id,0) != '0',h.social_city,s.social_city) = #{tDispatchInfo.socialCity}
</if>
<iftest="tDispatchInfo.socialTown != null and tDispatchInfo.socialTown!= null">
AND if(ifnull(h.id,0) != 0,h.social_town,s.social_town) = #{tDispatchInfo.socialTown}
AND if(ifnull(h.id,0) != '0',h.social_town,s.social_town) = #{tDispatchInfo.socialTown}
</if>
</if>
<iftest="tDispatchInfo.empName != null and tDispatchInfo.empName.trim() != ''">