/*社保代办理 1.派单审核通过 2.派增(type=0):待办理(social_handle_status='0') or 派减(type=1):已办理完成或部分办理失败 且已派减*/
a.DELETE_FLAG = '0'
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.SOCIAL_HANDLE_STATUS in ('0','4')
and a.AUTO_FLAG = '0'
<!--<if test="tDispatchInfo.status != null and tDispatchInfo.status.trim() != ''">
/*待办理组合判断*/
<if test="'2'.toString() == tDispatchInfo.status.trim() and tDispatchInfo.typeSub != null ">
if((sd.id is not null and NOW() <![CDATA[ <= ]]> sd.SOCIAL_END_DATE) or ( sd.id is null and DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')),0 ,1) YGS_OVER_DUE_FLAG
FROM t_social_info a
left join t_dispatch_info d on d.SOCIAL_ID = a.id
left join t_social_deadline_info sd on sd.MONTH = DATE_FORMAT(d.AUDIT_TIME,'%Y%m') and sd.STATUS = '0'
and sd.PROVINCE=a.SOCIAL_PROVINCE and sd.CITY=a.SOCIAL_CITY and ( (a.SOCIAL_TOWN is null and sd.TOWN is null) or (sd.TOWN=a.SOCIAL_TOWN))
where a.YGS_ADD_ID is not null and DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
where a.YGS_ADD_ID is not null and d.AUTO_FLAG='0'
and (DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m') or DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 MONTH),'%Y%m'))
and a.YGS_HANDLE_STATUS in ('1','2','3')
and (sd.id is null or NOW() <![CDATA[ <= ]]> sd.SOCIAL_END_DATE)
group by a.id
</select>
...
...
@@ -609,14 +612,15 @@
a.YSD_ADD_ID,
a.HANDLE_STATUS,
a.YSD_HANDLE_STATUS,
d.id as DISPATCH_ID
d.id as DISPATCH_ID,
if((sd.id is not null and NOW() <![CDATA[ <= ]]> sd.MEDICAL_END_DATE) or ( sd.id is null and DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')),0 ,1) YSD_OVER_DUE_FLAG
FROM t_social_info a
left join t_dispatch_info d on d.SOCIAL_ID = a.id
left join t_social_deadline_info sd on sd.MONTH = DATE_FORMAT(d.AUDIT_TIME,'%Y%m') and sd.STATUS = '0'
and sd.PROVINCE=a.SOCIAL_PROVINCE and sd.CITY=a.SOCIAL_CITY and ( (a.SOCIAL_TOWN is null and sd.TOWN is null) or (sd.TOWN=a.SOCIAL_TOWN))
where a.YSD_ADD_ID is not null and DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m')
where a.YSD_ADD_ID is not null and d.AUTO_FLAG='0'
and (DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(now(),'%Y%m') or DATE_FORMAT(d.AUDIT_TIME,'%Y%m') = DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 MONTH),'%Y%m'))
and a.YSD_HANDLE_STATUS in ('1','2','3')
and (sd.id is null or NOW() <![CDATA[ <= ]]> sd.MEDICAL_END_DATE)