<?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="com.sunxung.factoring.mapper.sys.ClientUserMapper">


	<select id="pageList" resultType="com.sunxung.factoring.entity.sys.vo.ClientUserVO"
		parameterType="com.sunxung.factoring.entity.sys.request.ClientUserQueryRequest">
		select
			a.id,
			a.user_name,
			a.login_name,
			a.mobile "phone",
			d.name "provinceName",
			e.name "cityName",
		  a.enterprise_address,
			a.gmt_create,
			b.`name` "project_manager",
			c.`name` "risk_manager"
		from  c_sys_user a
		LEFT JOIN sys_user b on a.project_manager = b.id
		LEFT JOIN sys_user c on  a.risk_manager = c.id
		LEFT JOIN t_org d on a.province_id = d.id
		LEFT JOIN t_org e on a.city_id = e.id
    <where>
			<if test="mark !=null and mark !='' ">
				 and (a.id = #{mark}  or a.mobile like CONCAT('%',#{mark},'%') )
			</if>
<!--      <if test="useMoney !=null ">-->
<!--				and  -->
<!--			</if>-->
      <if test=" managerName !=null and managerName !=''  ">
        and (b.name like CONCAT('%',#{managerName},'%') or  c.name like CONCAT('%',#{managerName},'%'))
			</if>
		</where>
	</select>


	<select id="getCompanyByClientUserId"
		resultType="com.sunxung.factoring.entity.sys.vo.ClientUserCompanyInfoVO"
		parameterType="java.lang.Long">
		select
			a.sys_user_id,
			b.corporate_name AS "mainCompany",
			b.address AS "enterpriseAddress"
		from c_supplier_info a
		JOIN c_enterprise b on  a.c_enterprise_id = b.id
    where a.sys_user_id = #{id}
	</select>
</mapper>
