
select w.id id,
		w.userid userid,
		w.belong_unitid belong_unitid,
		w.dutiesid dutiesid,
		os.id as overtimepay_strategyid,
		ds.id as duty_strategyid,
		ts.id as traffic_subsidyid,
		ms.id as megathermal_subsidyid,
		mes.id as fixedmeals_subsidyid,
		mes1.id as nofixedmeals_subsidyid,
		ots.id as other_subsidyid,
		sss.id as social_security_strategyid,
		pfs.id as provident_fund_strategyid,
		w.append_pay append_pay,
		w.deduct_pay deduct_pay,
		w.daikou_fee daikou_fee,
		w.jiaojin_subsidyid jiaojin_subsidyid,
		w.project_performance project_performance,
		w.onlychild_pay onlychild_pay,
		w.strategy_type as strategy_type,
	u.realname,u.username,sus.userNum as userNum, dt.departname,d.id as departid,du.duties_name as dutiesname,du.id as dutid,u.id as userids from t_s_base_user u 
	left join t_bus_user_wagestrategy w on u.id = w.userid 
	left join t_s_user sus on u.id= sus.id 
	LEFT JOIN t_s_user_org uo ON u.ID = uo.user_id and uo.ifpluralism = 0 and uo.status = 0
	left join t_s_depart d on uo.org_id = d.id 
	left join t_s_depart dt on w.pjt_id = dt.id 
	left join t_bus_user_personnel p on p.userid = u.id 
	left join t_bus_duties du on du.id = p.belong_dutiesid
	LEFT JOIN t_bus_overtimepay_strategy os
	    ON w.overtimepay_strategyid = os.id and os.status = '0' and os.delete_flag = '0'
	LEFT JOIN t_bus_dutyfee_strategy ds
	    ON w.duty_strategyid = ds.id and ds.status = '0' and ds.delete_flag = '0'
	LEFT JOIN t_bus_traffic_subsidy ts
	    ON w.traffic_subsidyid = ts.id and ts.status = '0' and ts.delete_flag = '0'
	LEFT JOIN t_bus_megathermal_subsidy ms
	    ON w.megathermal_subsidyid = ms.id and ms.status = '0' and ms.delete_flag = '0'
	LEFT JOIN t_bus_meals_subsidy mes
	    ON w.fixedmeals_subsidyid = mes.id and mes.status = '0' and mes.delete_flag = '0' and mes.subsidy_type = 'anyueguding'
	LEFT JOIN t_bus_meals_subsidy mes1
	    ON w.nofixedmeals_subsidyid = mes1.id and mes1.status = '0' and mes1.delete_flag = '0' and mes1.subsidy_type = 'anciguding'
	LEFT JOIN t_bus_other_subsidy ots
	    ON w.other_subsidyid = ots.id and ots.status = '0' and ots.delete_flag = '0'
	LEFT JOIN t_bus_social_security_strategy sss
	    ON w.social_security_strategyid = sss.id and sss.status = '0' and sss.delete_flag = '0'
	LEFT JOIN t_bus_provident_fund_strategy pfs
	    ON w.provident_fund_strategyid = pfs.id and pfs.status = '0' and pfs.delete_flag = '0'
where u.id in (
			select bu.id as userid from t_bus_user_personnel per 
			left join t_s_base_user bu on bu.id = per.userid
			where leave_date is null and not exists (select * from t_bus_user_wagestrategy uwage where uwage.userid = per.userid)
			union all
			select bu.id as userid 
			from t_bus_user_wagestrategy uwage 
			left join t_s_base_user bu on bu.id = uwage.userid 
			left join t_s_user_org uorg on uorg.user_id = bu.id and uorg.ifpluralism = '0' and uorg.status='0'
			left join t_bus_user_personnel per  on per.userid = bu.id
			where uwage.belong_unitid <> uorg.org_id and leave_date is null)
		and u.delete_flag != '1'
		<#if (userWagestrategyDao.username )?? && userWagestrategyDao.username ?length gt 0>
		    /* 转正人编号 */
			and u.username like CONCAT('%', :userWagestrategyDao.username ,'%') 
		</#if>
		<#if (userWagestrategyDao.realname )?? && userWagestrategyDao.realname ?length gt 0>
		    /* 转正人名称 */
			and u.realname like CONCAT('%', :userWagestrategyDao.realname ,'%') 
		</#if>
		<#if ( userWagestrategyDao.orgIdList )?? && userWagestrategyDao.orgIdList ?size gt 0>
		    /* 所属单位*/
			and d.id in(
			<#list userWagestrategyDao.orgIdList as item>
			   '${item}'
			 <#if item_has_next>,</#if>
			 </#list>
			)
		</#if>
		<#if ( useridList )?? && useridList ?size gt 0>
		    /* 可见的用户id */
			and u.id in(
			<#list useridList as item>   
			   '${item}'
			 <#if item_has_next>,</#if>
			 </#list>
			)
		</#if>