<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="clientAccountSqlMapper">

	<select id="findOperatorByParams"  parameterType="map" resultType="com.cloudcross.ssp.model.ClientAccount">
		 select t_account.id as id,t_account.name as accountName,
    t_operator.company_name as companyName, t_operator.link_man as linkMan,
    t_operator.tel as mobilePhone,t_account.tel as tel,t_account.state as status,t_account.sys_type as sysType from
    t_operator,t_account where t_account.id = t_operator.admin_id and t_account.state != -1 and t_operator.status != -1 and t_account.sys_type = 2  
		<if test="value!=null">
			and (t_account.name like #{value}
			or t_operator.company_name like #{value})
		</if>
		order by  t_account.id   desc
	</select>
	
	<select id="countOperatorByParams" parameterType="map" resultType="int">
		select count(t_account.id) 
    	 from
    	t_operator,t_account where t_account.id = t_operator.admin_id 
    	and t_account.state != -1 
    	and t_operator.status != -1 and t_account.sys_type = 2
		<if test="value!=null">
			and (t_account.name like #{value}
			or t_operator.company_name like #{value})
		</if>
	</select>
	
	<select id="findAgentByParams"  parameterType="map" resultType="com.cloudcross.ssp.model.ClientAccount">
		 select t_account.id as id,t_account.name as accountName,
    t_adv_agent.name as companyName, t_adv_agent.contacts as linkMan,
    t_adv_agent.mobile as mobilePhone,t_adv_agent.tel as tel,t_account.state as status,t_account.sys_type as sysType from
    t_adv_agent,t_account where t_account.id = t_adv_agent.admin_id and t_account.state != -1 and t_adv_agent.status != -1 and t_account.sys_type = 3
		<if test="value!=null">
			and (t_account.name like #{value}
			or t_adv_agent.name like #{value})
		</if>
		order by  t_account.id   desc
	</select>
	
	<select id="countAgentByParams" parameterType="map" resultType="int">
		 select count(t_account.id) from
     t_adv_agent,t_account where t_account.id = t_adv_agent.admin_id 
     and t_account.state != -1 and t_adv_agent.status != -1 and t_account.sys_type = 3
		<if test="value!=null">
			and (t_account.name like #{value}
			or t_adv_agent.name like #{value})
		</if>
	</select>

</mapper>