case a.SOCIAL_HANDLE_STATUS when '0' then '未办理' when '1' then '全部办理成功' when '2' then '全部办理失败' when '3' then '部分办理成功' when '4' then '办理中' else '-' end socialHandleStatus,
case if(ifnull(h.id,0) != '0',h.PENSION_HANDLE,s.PENSION_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end pensionHandle,
case if(ifnull(h.id,0) != '0',h.MEDICAL_HANDLE,s.MEDICAL_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end medicalHandle,
case if(ifnull(h.id,0) != '0',h.UNEMPLOY_HANDLE,s.UNEMPLOY_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end unemployHandle,
case if(ifnull(h.id,0) != '0',h.WORK_INJURY_HANDLE,s.WORK_INJURY_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end workInjuryHandle,
case if(ifnull(h.id,0) != '0',h.BIRTH_HANDLE,s.BIRTH_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end birthHandle,
case if(ifnull(h.id,0) != '0',h.BIGAILMENT_HANDLE,s.BIGAILMENT_HANDLE) when '0' then '派增待办理' when '1' then '派增办理成功' when '2' then '派增办理失败' when '3' then '派减-已派减' when '4' then '派减失败' when '5' then '派减待办理' else '——' end bigailmentHandle,
a.EMP_NAME empName,
a.EMP_IDCARD empIdcard,
a.EDUCATION_NAME educationName,
a.BELONG_UNIT_NAME belongUnit,
a.SETTLE_DOMAIN_NAME settleDomain,
emp_natrue.label empType,
a.POST post,
a.EMP_MOBILE empMobile,
a.ID_CARD_ADDRESS idCardAddress,
a.CONTACT_ADDRESS contactAddress,
registype.label regisType,
nation.label empNational,
workingHours.label workingHours,
a.CONTRACT_TERM contractTerm,
s.SOCIAL_START_DATE contractStart,
a.CONTRACT_END contractEnd,
a.CREATE_NAME createUserName,
s.RECORD_BASE recordBase,
case s.PAYMENT_TYPE when '0' then '最低' when '1' then '自定义' when '2' then '最高' else '-' end paymentType,
/*社保代办理 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')) ))