|  | @@ -56,10 +56,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
	
		
			
				|  |  |          <result property="clueId"    column="clue_id"    />
 | 
	
		
			
				|  |  |          <result property="customerLevel"    column="customer_level"    />
 | 
	
		
			
				|  |  |          <result property="isTop"    column="is_top"    />
 | 
	
		
			
				|  |  | +        <result property="visitType"    column="visit_type"    />
 | 
	
		
			
				|  |  | +        <result property="visitContent"    column="visit_content"    />
 | 
	
		
			
				|  |  |      </resultMap>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <sql id="selectCrmCustomerVo">
 | 
	
		
			
				|  |  | -        select customer_id, customer_code, customer_name, mobile, sex, weixin, remark, user_id, create_user_id, receive_user_id, customer_user_id, address,city_ids, location, detail_address, lng, lat, create_time, update_time, status, is_receive, dept_id, is_del, customer_type, receive_time, pool_time, company_id, is_line, source, tags,ext_json,visit_status,register_date,register_link_url,register_desc,register_submit_time,is_pool,register_type,pay_money,buy_count,source_code,push_time,push_code,visit_time,traffic_source,import_type,third_account,clue_id,customer_level,is_top from crm_customer
 | 
	
		
			
				|  |  | +        select customer_id, customer_code, customer_name, mobile, sex, weixin, remark, user_id, create_user_id,
 | 
	
		
			
				|  |  | +               receive_user_id, customer_user_id, address,city_ids, location, detail_address, lng, lat, create_time,
 | 
	
		
			
				|  |  | +               update_time, status, is_receive, dept_id, is_del, customer_type, receive_time, pool_time, company_id,
 | 
	
		
			
				|  |  | +               is_line, source, tags,ext_json,visit_status,register_date,register_link_url,register_desc,
 | 
	
		
			
				|  |  | +               register_submit_time,is_pool,register_type,pay_money,buy_count,source_code,push_time,push_code,
 | 
	
		
			
				|  |  | +               visit_time,traffic_source,import_type,third_account,clue_id,customer_level,is_top,visit_type,visit_content from crm_customer
 | 
	
		
			
				|  |  |      </sql>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="selectCrmCustomerList" parameterType="CrmCustomer" resultMap="CrmCustomerResult">
 | 
	
	
		
			
				|  | @@ -97,6 +104,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
	
		
			
				|  |  |              <if test="clueId != null "> and clue_id = #{clueId}</if>
 | 
	
		
			
				|  |  |              <if test="customerLevel != null "> and customer_level = #{customerLevel}</if>
 | 
	
		
			
				|  |  |              <if test="isTop != null "> and is_top = #{isTop}</if>
 | 
	
		
			
				|  |  | +            <if test="visitType != null"> and visit_type = #{visitType}</if>
 | 
	
		
			
				|  |  | +            <if test="visitContent != null and visitContent !=''"> and visit_content = #{visitContent}</if>
 | 
	
		
			
				|  |  |          </where>
 | 
	
		
			
				|  |  |          order by customer_id desc
 | 
	
		
			
				|  |  |      </select>
 | 
	
	
		
			
				|  | @@ -163,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
	
		
			
				|  |  |              <if test="clueId != null">clue_id,</if>
 | 
	
		
			
				|  |  |              <if test="customerLevel != null">customer_level,</if>
 | 
	
		
			
				|  |  |              <if test="isTop != null">is_top,</if>
 | 
	
		
			
				|  |  | +            <if test="visitType != null">visit_type,</if>
 | 
	
		
			
				|  |  | +            <if test="visitContent != null">visit_content,</if>
 | 
	
		
			
				|  |  |           </trim>
 | 
	
		
			
				|  |  |          <trim prefix="values (" suffix=")" suffixOverrides=",">
 | 
	
		
			
				|  |  |              <if test="customerCode != null">#{customerCode},</if>
 | 
	
	
		
			
				|  | @@ -214,6 +225,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
	
		
			
				|  |  |              <if test="clueId != null">#{clueId},</if>
 | 
	
		
			
				|  |  |              <if test="customerLevel != null">#{customerLevel},</if>
 | 
	
		
			
				|  |  |              <if test="isTop != null">#{isTop},</if>
 | 
	
		
			
				|  |  | +            <if test="visitType != null">#{visitType},</if>
 | 
	
		
			
				|  |  | +            <if test="visitContent != null">#{visitContent},</if>
 | 
	
		
			
				|  |  |           </trim>
 | 
	
		
			
				|  |  |      </insert>
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -269,6 +282,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
	
		
			
				|  |  |              <if test="clueId != null">clue_id = #{clueId},</if>
 | 
	
		
			
				|  |  |              <if test="customerLevel != null">customer_level = #{customerLevel},</if>
 | 
	
		
			
				|  |  |              <if test="isTop != null">is_top = #{isTop},</if>
 | 
	
		
			
				|  |  | +            <if test="visitType != null">visit_type = #{visitType},</if>
 | 
	
		
			
				|  |  | +            <if test="visitContent != null and visitContent !=''">visit_content = #{visitContent},</if>
 | 
	
		
			
				|  |  |          </trim>
 | 
	
		
			
				|  |  |          where customer_id = #{customerId}
 | 
	
		
			
				|  |  |      </update>
 | 
	
	
		
			
				|  | @@ -303,7 +318,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
	
		
			
				|  |  |      <select id="selectCrmMyCustomerListQuery" resultType="com.fs.crm.vo.CrmMyCustomerListQueryVO">
 | 
	
		
			
				|  |  |          select cu.*,c.create_time as customer_create_time,c.visit_status,c.remark,c.register_desc,c.register_submit_time,
 | 
	
		
			
				|  |  |                 c.customer_code,c.customer_name,c.mobile,c.sex,c.weixin,c.address,c.is_receive,c.customer_type,c.source,
 | 
	
		
			
				|  |  | -               c.tags,c.receive_time,c.customer_level
 | 
	
		
			
				|  |  | +               c.tags,c.receive_time,c.customer_level,c.pay_money,c.visit_content
 | 
	
		
			
				|  |  |          from crm_customer_user cu
 | 
	
		
			
				|  |  |              inner join crm_customer c on c.customer_user_id=cu.customer_user_id
 | 
	
		
			
				|  |  |          where cu.is_pool=0  and c.is_del = 0
 | 
	
	
		
			
				|  | @@ -442,4 +457,158 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
	
		
			
				|  |  |      <select id="selectCustomerIdByCompanyUserId" resultType="java.lang.Long">
 | 
	
		
			
				|  |  |          SELECT customer_id FROM crm_customer_user where company_user_id = #{companyUserId}
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  | +    <select id="selectCrmCustomerListQueryParam" resultType="com.fs.crm.vo.CrmCustomerListVO">
 | 
	
		
			
				|  |  | +        select c.*,com.company_name,cu.nick_name as company_user_nick_name,ccu.last_time as lastTime
 | 
	
		
			
				|  |  | +        from crm_customer c
 | 
	
		
			
				|  |  | +            left join company com on com.company_id=c.company_id
 | 
	
		
			
				|  |  | +            left join company_user cu on cu.user_id=c.receive_user_id
 | 
	
		
			
				|  |  | +            left join crm_customer_user ccu on ccu.customer_user_id = c.customer_user_id
 | 
	
		
			
				|  |  | +        <where>
 | 
	
		
			
				|  |  | +            <if test="maps.companyId != null">
 | 
	
		
			
				|  |  | +                and c.company_id =#{maps.companyId}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.customerCode != null and  maps.customerCode != ''">
 | 
	
		
			
				|  |  | +                and c.customer_code like CONCAT('%',#{maps.customerCode},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.customerName != null and  maps.customerName != ''">
 | 
	
		
			
				|  |  | +                and c.customer_name like CONCAT('%',#{maps.customerName},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.companyUserNickName != null and  maps.companyUserNickName != ''">
 | 
	
		
			
				|  |  | +                and c.nick_name like CONCAT('%',#{maps.companyUserNickName},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.mobile != null and  maps.mobile != ''">
 | 
	
		
			
				|  |  | +                and c.mobile like CONCAT('%',#{maps.mobile},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.tags != null and  maps.tags != ''">
 | 
	
		
			
				|  |  | +                and find_in_set(#{maps.tags}, c.tags)
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.status != null">
 | 
	
		
			
				|  |  | +                and c.status =#{maps.status}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.visitStatus != null and  maps.visitStatus != ''">
 | 
	
		
			
				|  |  | +                and c.visit_status =#{maps.visitStatus}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.customerType != null">
 | 
	
		
			
				|  |  | +                and c.customer_type IN
 | 
	
		
			
				|  |  | +                <foreach collection="maps.customerType.split(',')" item='item' index='index'  open='(' separator=',' close=')'>
 | 
	
		
			
				|  |  | +                    #{item}
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isLine != null">
 | 
	
		
			
				|  |  | +                and c.is_line =#{maps.isLine}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isBuy != null and maps.isBuy==1">
 | 
	
		
			
				|  |  | +                and c.buy_count > 0
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isBuy != null and maps.isBuy==0">
 | 
	
		
			
				|  |  | +                and (c.buy_count = 0 or c.buy_count is null)
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.source != null ">
 | 
	
		
			
				|  |  | +                and c.source IN
 | 
	
		
			
				|  |  | +                <foreach collection="maps.source.split(',')" item='item' index='index'  open='(' separator=',' close=')'>
 | 
	
		
			
				|  |  | +                    #{item}
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.beginTime != null and maps.beginTime != ''">
 | 
	
		
			
				|  |  | +                and date_format(c.create_time,'%y%m%d') >= date_format(#{maps.beginTime},'%y%m%d')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.endTime != null and maps.endTime != ''">
 | 
	
		
			
				|  |  | +                and date_format(c.create_time,'%y%m%d') <= date_format(#{maps.endTime},'%y%m%d')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.receiveTimeList != null   ">
 | 
	
		
			
				|  |  | +                AND date_format(c.receive_time,'%y%m%d') >= date_format(#{maps.receiveTimeList[0]},'%y%m%d')
 | 
	
		
			
				|  |  | +                AND date_format(c.receive_time,'%y%m%d') <= date_format(#{maps.receiveTimeList[1]},'%y%m%d')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.deptId != null  and maps.deptId != 0 ">
 | 
	
		
			
				|  |  | +                AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.customerLevel != null  ">
 | 
	
		
			
				|  |  | +                and c.customer_level = #{maps.customerLevel}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +        </where>
 | 
	
		
			
				|  |  | +        ${maps.params.dataScope}
 | 
	
		
			
				|  |  | +        order by c.is_top desc, c.customer_id desc
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +    <select id="selectCrmCustomerListQuery" resultType="com.fs.crm.vo.CrmCustomerListQueryVO">
 | 
	
		
			
				|  |  | +        select c.*,u.nick_name as company_user_nick_name,ccu.start_time as startTime
 | 
	
		
			
				|  |  | +        from  crm_customer c
 | 
	
		
			
				|  |  | +            left join company_user u on u.user_id=c.receive_user_id
 | 
	
		
			
				|  |  | +            left join crm_customer_user ccu on c.customer_user_id = ccu.customer_user_id
 | 
	
		
			
				|  |  | +        <where>
 | 
	
		
			
				|  |  | +            <if test="maps.companyId != null">
 | 
	
		
			
				|  |  | +                and c.company_id =#{maps.companyId}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.companyUserNickName != null and  maps.companyUserNickName != ''">
 | 
	
		
			
				|  |  | +                and u.nick_name like CONCAT('%',#{maps.companyUserNickName},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.companyUserId != null    ">
 | 
	
		
			
				|  |  | +                and c.company_user_id =#{maps.companyUserId}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.customerCode != null and  maps.customerCode != ''">
 | 
	
		
			
				|  |  | +                and c.customer_code like CONCAT('%',#{maps.customerCode},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.customerName != null and  maps.customerName != '' ">
 | 
	
		
			
				|  |  | +                and c.customer_name like CONCAT('%',#{maps.customerName},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.mobile != null and  maps.mobile != '' ">
 | 
	
		
			
				|  |  | +                and c.mobile like CONCAT('%',#{maps.mobile},'%')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.status != null and  maps.status != '' ">
 | 
	
		
			
				|  |  | +                and c.status =#{maps.status}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.visitStatus != null">
 | 
	
		
			
				|  |  | +                and c.visit_status IN
 | 
	
		
			
				|  |  | +                <foreach collection="maps.visitStatus.split(',')" item="item" index="index" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                    #{item}
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isBuy != null and  maps.isBuy == 1 ">
 | 
	
		
			
				|  |  | +                and c.buy_count > 0
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isBuy != null and  maps.isBuy == 0 ">
 | 
	
		
			
				|  |  | +                and (c.buy_count = 0 or c.buy_count is null)
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isHisOrder != null and maps.isHisOrder==1">
 | 
	
		
			
				|  |  | +                and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  > 0
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isHisOrder != null and maps.isHisOrder==0  ">
 | 
	
		
			
				|  |  | +                and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id )  = 0
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.customerType != null    ">
 | 
	
		
			
				|  |  | +                and c.customer_type IN
 | 
	
		
			
				|  |  | +                <foreach collection="maps.customerType.split(',')" item="item" index="index" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                    #{item}
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.source != null and maps.source != ''">
 | 
	
		
			
				|  |  | +                and c.source IN
 | 
	
		
			
				|  |  | +                <foreach collection="maps.source.split(',')" item="item" index="index" open="(" separator="," close=")">
 | 
	
		
			
				|  |  | +                    #{item}
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isReceive != null">
 | 
	
		
			
				|  |  | +                and c.is_receive =#{maps.isReceive}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.isLine != null">
 | 
	
		
			
				|  |  | +                and c.is_line =#{maps.isLine}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.tags != null">
 | 
	
		
			
				|  |  | +                and
 | 
	
		
			
				|  |  | +                <foreach collection="maps.tags.split(',')" item="tag" open="(" separator="OR" close=")">
 | 
	
		
			
				|  |  | +                    find_in_set(#{tag},c.tags)
 | 
	
		
			
				|  |  | +                </foreach>
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.beginTime != null and maps.beginTime != ''">
 | 
	
		
			
				|  |  | +                and date_format(c.create_time,'%y%m%d') >= date_format(#{maps.beginTime},'%y%m%d')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.endTime != null and maps.endTime != ''">
 | 
	
		
			
				|  |  | +                and date_format(c.create_time,'%y%m%d') <= date_format(#{maps.endTime},'%y%m%d')
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="maps.deptId != null and maps.deptId != 0">
 | 
	
		
			
				|  |  | +                AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +        </where>
 | 
	
		
			
				|  |  | +        ${maps.params.dataScope}
 | 
	
		
			
				|  |  | +       order by c.customer_id desc
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  |  </mapper>
 |