| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- <?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.linkwechat.mapper.WeCustomerMapper">
- <update id="updateDelByUpdate">
- update we_customer wcr
- set wcr.del_flag=1
- where date_format(wcr.update_time,'%Y-%m-%d') != date_format(#{date},'%Y-%m-%d')
- and wcr.del_flag=0
- </update>
- <select id="findWeCustomerListIds" resultType="java.lang.String">
- SELECT wcr.id FROM we_customer wcr
- <where>
- <if test="weCustomerList.gender !=null">
- AND wcr.gender=#{weCustomerList.gender}
- </if>
- <if test="weCustomerList.source !=null">
- AND wcr.source=#{weCustomerList.source}
- </if>
- <if test="weCustomerList.trackState !=null">
- AND wcr.track_state=#{weCustomerList.trackState}
- </if>
- <if test="weCustomerList.addMethod !=null">
- AND wcr.add_method=#{weCustomerList.addMethod}
- </if>
- <if test="weCustomerList.customerType !=null">
- AND wcr.customer_type=#{weCustomerList.customerType}
- </if>
- <if test="weCustomerList.externalUserid !=null">
- AND wcr.external_userid=#{weCustomerList.externalUserid}
- </if>
- <if test="weCustomerList.firstUserId !=null">
- AND wcr.add_user_id=#{weCustomerList.firstUserId}
- </if>
- <if test="weCustomerList.delFlag != null">
- AND wcr.del_flag = #{weCustomerList.delFlag}
- </if>
- <if test="weCustomerList.name != null and weCustomerList.name !=''">
- AND CONCAT( IFNULL(wcr.customer_name,''))
- LIKE CONCAT('%',#{weCustomerList.name,jdbcType=VARCHAR},'%')
- </if>
- <if test="weCustomerList.userIds !=null and weCustomerList.userIds !=''">
- AND wcr.add_user_id in
- <foreach collection="weCustomerList.userIds.split(',')" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="weCustomerList.tagIds !=null and weCustomerList.tagIds !=''">
- <foreach item="tagId" index="index" collection="weCustomerList.tagIds.split(',')">
- AND FIND_IN_SET(#{tagId},wcr.tag_ids)
- </foreach>
- </if>
- <if test="weCustomerList.noTagCheck">
- AND ISNULL(wcr.tag_ids) or LENGTH(TRIM(wcr.tag_ids)) =0
- </if>
- <if test="weCustomerList.excludeTagIds !=null and weCustomerList.excludeTagIds !=''">
- <foreach item="excludeTagId" index="index" collection="weCustomerList.excludeTagIds.split(',')">
- AND !FIND_IN_SET(#{excludeTagId},wcr.tag_ids)
- </foreach>
- </if>
- <if test="weCustomerList.beginTime !=null and weCustomerList.beginTime != '' and weCustomerList.endTime !='' and weCustomerList.endTime != null">
- AND date_format(wcr.add_time,'%Y-%m-%d') BETWEEN #{weCustomerList.beginTime} AND #{weCustomerList.endTime}
- </if>
- </where>
- ORDER BY wcr.add_time desc
- <if test="pageDomain !=null">
- <if test="pageDomain.pageNum !=null and pageDomain.pageSize !=null">
- limit ${pageDomain.pageSize * (pageDomain.pageNum-1)}, #{pageDomain.pageSize}
- </if>
- </if>
- </select>
- <select id="findWeUserIds" resultType="java.lang.String">
- select we_user_id from sys_user
- </select>
- <select id="findWeCustomerListIdsByApp" resultType="java.lang.String">
- SELECT wcr.id FROM we_customer wcr
- LEFT JOIN sys_user su on su.we_user_id=wcr.add_user_id
- <where>
- <if test="weCustomerList.name != null and weCustomerList.name !=''">
- AND CONCAT( IFNULL(wcr.customer_name,''),IFNULL(su.user_name,''))
- LIKE CONCAT('%',#{weCustomerList.name,jdbcType=VARCHAR},'%')
- </if>
- <if test="weCustomerList.customerType !=null">
- AND wcr.customer_type=#{weCustomerList.customerType}
- </if>
- <if test="weCustomerList.trackState !=null">
- AND wcr.track_state=#{weCustomerList.trackState}
- </if>
- <if test="weCustomerList.addMethod !=null">
- AND wcr.add_method=#{weCustomerList.addMethod}
- </if>
- <if test="weCustomerList.tagIds !=null and weCustomerList.tagIds !=''">
- <foreach item="tagId" index="index" collection="weCustomerList.tagIds.split(',')">
- AND FIND_IN_SET(#{tagId},wcr.tag_ids)
- </foreach>
- </if>
- <if test="weCustomerList.beginTime !=null and weCustomerList.beginTime != '' and weCustomerList.endTime !='' and weCustomerList.endTime != null">
- AND date_format(wcr.add_time,'%Y-%m-%d') BETWEEN #{weCustomerList.beginTime} AND #{weCustomerList.endTime}
- </if>
- <if test="weCustomerList.firstUserId !=null">
- AND wcr.add_user_id=#{weCustomerList.firstUserId}
- </if>
- <if test="weCustomerList.delFlag != null">
- AND wcr.del_flag = #{weCustomerList.delFlag}
- </if>
- </where>
- ORDER BY wcr.add_time desc
- <if test="pageDomain !=null">
- <if test="pageDomain.pageNum !=null and pageDomain.pageSize !=null">
- limit ${pageDomain.pageSize * (pageDomain.pageNum-1)}, #{pageDomain.pageSize}
- </if>
- </if>
- </select>
- <select id="countWeCustomerListByApp" resultType="long">
- SELECT count(wcr.id) FROM we_customer wcr
- LEFT JOIN sys_user su on su.we_user_id=wcr.add_user_id
- <where>
- <if test="weCustomerList.name != null and weCustomerList.name !=''">
- AND CONCAT( IFNULL(wcr.customer_name,''),IFNULL(su.user_name,''))
- LIKE CONCAT('%',#{weCustomerList.name,jdbcType=VARCHAR},'%')
- </if>
- <if test="weCustomerList.customerType !=null">
- AND wcr.customer_type=#{weCustomerList.customerType}
- </if>
- <if test="weCustomerList.trackState !=null">
- AND wcr.track_state=#{weCustomerList.trackState}
- </if>
- <if test="weCustomerList.addMethod !=null">
- AND wcr.add_method=#{weCustomerList.addMethod}
- </if>
- <if test="weCustomerList.tagIds !=null and weCustomerList.tagIds !=''">
- <foreach item="tagId" index="index" collection="weCustomerList.tagIds.split(',')">
- AND FIND_IN_SET(#{tagId},wcr.tag_ids)
- </foreach>
- </if>
- <if test="weCustomerList.beginTime !=null and weCustomerList.beginTime != '' and weCustomerList.endTime !='' and weCustomerList.endTime != null">
- AND date_format(wcr.add_time,'%Y-%m-%d') BETWEEN #{weCustomerList.beginTime} AND #{weCustomerList.endTime}
- </if>
- <if test="weCustomerList.firstUserId !=null">
- AND wcr.add_user_id=#{weCustomerList.firstUserId}
- </if>
- <if test="weCustomerList.delFlag != null">
- AND wcr.del_flag = #{weCustomerList.delFlag}
- </if>
- </where>
- </select>
- <select id="findWeCustomerList" resultType="com.linkwechat.domain.customer.vo.WeCustomersVo">
- SELECT
- wc.id,
- wc.unionid,
- wc.avatar,
- wc.customer_name,
- wc.customer_full_name,
- wc.customer_type as customerType,
- wc.external_userid,
- wc.add_user_id as firstUserId,
- wc.track_state,
- wc.add_method,
- wc.add_time as firstAddTime,
- wc.birthday,
- wc.gender,
- MOBILE_MASK(wc.phone) phone,
- wc.email,
- wc.address,
- wc.qq,
- wc.source,
- wc.position,
- wc.corp_name as corpName,
- wc.other_descr as otherDescr,
- timestampdiff(day,wc.add_time,NOW()) as retentionDays,
- (SELECT GROUP_CONCAT(DISTINCT wu.user_name) FROM sys_user wu WHERE wu.we_user_id=wc.add_user_id) as userName,
- (SELECT GROUP_CONCAT(wt.tag_id) FROM we_flower_customer_tag_rel wfctr
- LEFT JOIN we_tag wt ON wt.tag_id= wfctr.tag_id
- WHERE wfctr.external_userid=wc.external_userid AND wc.add_user_id=wfctr.user_id AND wt.tag_type=3 and wfctr.del_flag=0) as personTagIds,
- (SELECT GROUP_CONCAT(wt.name) FROM we_flower_customer_tag_rel wfctr
- LEFT JOIN we_tag wt ON wt.tag_id= wfctr.tag_id
- WHERE wfctr.external_userid=wc.external_userid AND wc.add_user_id=wfctr.user_id AND wt.tag_type=3 and wfctr.del_flag=0) as personTagNames,
- (SELECT GROUP_CONCAT(wt.name) FROM we_flower_customer_tag_rel wfctr
- LEFT JOIN we_tag wt ON wt.tag_id= wfctr.tag_id
- WHERE wfctr.external_userid=wc.external_userid AND wc.add_user_id=wfctr.user_id AND wt.tag_type=1 and wfctr.del_flag=0) as tagNames,
- (SELECT GROUP_CONCAT(wt.tag_id) FROM we_flower_customer_tag_rel wfctr
- LEFT JOIN we_tag wt ON wt.tag_id= wfctr.tag_id
- WHERE wfctr.external_userid=wc.external_userid AND wc.add_user_id=wfctr.user_id AND wt.tag_type=1 and wfctr.del_flag=0) as tagIds,
- wc.update_time as updateTime,
- IF(wc.del_flag = 0,'有效','无效') as delFlagName,
- IF(wc.del_flag = 1, (case when wc.del_flag_ba = 1 and wc.del_flag_bei = 0 then '客户删除员工'
- when wc.del_flag_ba = 0 and wc.del_flag_bei = 1 then '员工删除客户'
- when wc.del_flag_ba = 1 and wc.del_flag_bei = 1 then '双向删除'
- else '未知'
- end), '正常') as delFlagStatus
- FROM
- we_customer wc
- WHERE
- wc.id in
- <foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- ORDER BY wc.add_time desc
- </select>
- <select id="countWeCustomerList" resultType="long">
- SELECT count(0) FROM we_customer wcr
- <where>
- <if test="weCustomerList.gender !=null">
- AND wcr.gender=#{weCustomerList.gender}
- </if>
- <if test="weCustomerList.source !=null">
- AND wcr.source=#{weCustomerList.source}
- </if>
- <if test="weCustomerList.trackState !=null">
- AND wcr.track_state=#{weCustomerList.trackState}
- </if>
- <if test="weCustomerList.addMethod !=null">
- AND wcr.add_method=#{weCustomerList.addMethod}
- </if>
- <if test="weCustomerList.customerType !=null">
- AND wcr.customer_type=#{weCustomerList.customerType}
- </if>
- <if test="weCustomerList.externalUserid !=null">
- AND wcr.external_userid=#{weCustomerList.externalUserid}
- </if>
- <if test="weCustomerList.firstUserId !=null">
- AND wcr.add_user_id=#{weCustomerList.firstUserId}
- </if>
- <if test="weCustomerList.delFlag != null">
- AND wcr.del_flag = #{weCustomerList.delFlag}
- </if>
- <if test="weCustomerList.name != null and weCustomerList.name !=''">
- AND CONCAT( IFNULL(wcr.customer_name,''))
- LIKE CONCAT('%',#{weCustomerList.name,jdbcType=VARCHAR},'%')
- </if>
- <if test="weCustomerList.userIds !=null and weCustomerList.userIds !=''">
- AND wcr.add_user_id in
- <foreach collection="weCustomerList.userIds.split(',')" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="weCustomerList.tagIds !=null and weCustomerList.tagIds !=''">
- <foreach item="tagId" index="index" collection="weCustomerList.tagIds.split(',')">
- AND FIND_IN_SET(#{tagId},wcr.tag_ids)
- </foreach>
- </if>
- <if test="weCustomerList.beginTime !=null and weCustomerList.beginTime != '' and weCustomerList.endTime !='' and weCustomerList.endTime != null">
- AND date_format(wcr.add_time,'%Y-%m-%d') BETWEEN #{weCustomerList.beginTime} AND #{weCustomerList.endTime}
- </if>
- </where>
- </select>
- <select id="noRepeatCountCustomer" resultType="long">
- SELECT
- COUNT(DISTINCT wc.external_userid)
- FROM
- we_customer wc
- <where>
- <if test="weCustomerList.gender !=null">
- AND wc.gender=#{weCustomerList.gender}
- </if>
- <if test="weCustomerList.trackState !=null">
- AND wc.track_state=#{weCustomerList.trackState}
- </if>
- <if test="weCustomerList.addMethod !=null">
- AND wc.add_method=#{weCustomerList.addMethod}
- </if>
- <if test="weCustomerList.customerType !=null">
- AND wc.customer_type=#{weCustomerList.customerType}
- </if>
- <if test="weCustomerList.externalUserid !=null">
- AND wc.external_userid=#{weCustomerList.externalUserid}
- </if>
- <if test="weCustomerList.firstUserId !=null">
- AND wc.add_user_id=#{weCustomerList.firstUserId}
- </if>
- <if test="weCustomerList.delFlag != null">
- AND wc.del_flag = #{weCustomerList.delFlag}
- </if>
- <if test="weCustomerList.name != null and weCustomerList.name !=''">
- AND wc.customer_name like concat('%',#{weCustomerList.name,jdbcType=VARCHAR},'%')
- </if>
- <if test="weCustomerList.userIds !=null and weCustomerList.userIds !=''">
- AND wc.add_user_id in
- <foreach collection="weCustomerList.userIds.split(',')" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="weCustomerList.tagIds !=null and weCustomerList.tagIds !=''">
- <foreach item="tagId" index="index" collection="weCustomerList.tagIds.split(',')">
- AND FIND_IN_SET(#{tagId},tag_ids)
- </foreach>
- </if>
- <if test="weCustomerList.beginTime !=null and weCustomerList.beginTime != '' and weCustomerList.endTime !='' and weCustomerList.endTime != null">
- AND date_format(wc.add_time,'%Y-%m-%d') BETWEEN #{weCustomerList.beginTime} AND #{weCustomerList.endTime}
- </if>
- </where>
- </select>
- <select id="findWecustomerGroups" resultType="com.linkwechat.domain.customer.vo.WeCustomerDetailInfoVo$Groups">
- SELECT
- wg.chat_id,
- wg.group_name,
- wgm.join_time,
- wgm.join_scene,
- (SELECT distinct wu.user_name FROM sys_user wu WHERE wu.we_user_id=wg.owner) as leaderName
- FROM
- we_group_member wgm
- LEFT JOIN we_group wg ON wg.chat_id = wgm.chat_id
- WHERE wgm.del_flag=0 and wg.del_flag=0 AND wgm.user_id=#{userId}
- ORDER BY wgm.join_time
- </select>
- <select id="findUserNameByUserId" resultType="String">
- SELECT DISTINCT user_name FROM sys_user WHERE we_user_id=#{weUserId} and del_flag = 0
- </select>
- <select id="findCustomerByOperUseridAndCustomerId" resultType="com.linkwechat.domain.customer.vo.WeCustomerPortraitVo">
- SELECT
- wc.id as customerId,
- wc.customer_name as name,
- wc.other_descr as remark,
- wc.phone as remarkMobiles,
- wc.birthday,
- wc.email,
- wc.address,
- wc.qq,
- wc.position,
- wc.corp_name as remarkCorpName,
- wc.other_descr as description,
- wc.add_user_id as user_id,
- wc.avatar,
- wc.external_userid,
- wc.gender,
- wc.track_state,
- wc.customer_type,
- GROUP_CONCAT(if(wt.tag_type=1,wt.`tag_id`,null )) as tagIds,
- GROUP_CONCAT(if(wt.tag_type=1,wt.`name`,null )) as tagNames,
- GROUP_CONCAT(if(wt.tag_type=3,wt.`tag_id`,null )) as personTagIds,
- GROUP_CONCAT(if(wt.tag_type=3,wt.`name`,null )) as personTagNames,
- wc.track_content as content,
- wc.province_id,
- wc.city_id,
- wc.area_id,
- wc.area,
- wc.customer_full_name as customerFullName
- FROM
- we_customer wc
- LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.user_id = wc.add_user_id AND wfcrf.external_userid=wc.external_userid AND wfcrf.del_flag=0
- LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
- WHERE wc.external_userid=#{externalUserid} and wc.add_user_id=#{userid}
- </select>
- <select id="countSocialConn" resultType="com.linkwechat.domain.customer.vo.WeCustomerSocialConnVo">
- SELECT
- (
- SELECT
- count(DISTINCT wfcr.add_user_id)
- FROM
- we_customer wfcr WHERE wfcr.external_userid=wc.external_userid
- ) AS addEmployeNum,
- (
- SELECT
- COUNT(*)
- FROM
- we_group_member wgm where wgm.union_id=wc.external_userid
- ) AS addGroupNum,
- (
- SELECT
- COUNT(*)
- FROM we_group_member where chat_id in (
- SELECT
- chat_id
- FROM
- `we_group_member` where union_id=wc.external_userid
- ) and user_id=#{userid}
- ) AS commonGroupNum
- FROM we_customer wc WHERE wc.external_userid=#{externalUserid} and wc.add_user_id=#{userid}
- </select>
- <select id="findWeUserByCutomerId" resultType="com.linkwechat.domain.customer.vo.WeCustomerAddUserVo">
- SELECT
- wu.user_name,
- wc.add_user_id as userId,
- wu.avatar as headImageUrl,
- wc.add_time as createTime
- FROM
- we_customer wc
- INNER JOIN sys_user wu ON wc.add_user_id = wu.we_user_id
- WHERE wc.external_userid=#{externalUserid} and wu.del_flag=0
- </select>
- <insert id="batchAddOrUpdate">
- INSERT INTO we_customer(
- id,
- external_userid,
- customer_name,
- customer_full_name,
- avatar,
- customer_type,
- gender,
- unionid,
- birthday,
- corp_name,
- `position`,
- is_open_chat,
- create_time,
- create_by,
- add_user_id,
- add_time,
- qq,
- email,
- address,
- phone,
- add_method,
- del_flag,
- `state`,
- update_by,
- update_time,
- other_descr,
- remark_name,
- create_by_id,
- update_by_id,
- tag_ids
- ) values
- <foreach collection="weCustomers" item="item" index="index" separator=",">
- (#{item.id},#{item.externalUserid},#{item.customerName},#{item.customerFullName},#{item.avatar},#{item.customerType},#{item.gender}, #{item.unionid},#{item.birthday},
- #{item.corpName},#{item.position},#{item.isOpenChat}, #{item.createTime},
- #{item.createBy},#{item.addUserId},#{item.addTime},#{item.qq},#{item.email},#{item.address},#{item.phone},#{item.addMethod},#{item.delFlag},
- #{item.state},#{item.updateBy},#{item.updateTime},#{item.otherDescr},#{item.remarkName},#{item.createById},#{item.updateById},
- #{item.tagIds}
- )
- </foreach>
- ON DUPLICATE KEY UPDATE
- customer_name=IFNULL(VALUES(customer_name),we_customer.customer_name),
- customer_full_name=IFNULL(VALUES(customer_full_name),we_customer.customer_full_name),
- avatar=IFNULL(VALUES(avatar), we_customer.avatar),
- customer_type=IFNULL(VALUES(customer_type),we_customer.customer_type),
- gender=IFNULL(VALUES(gender), we_customer.gender),
- unionid=IFNULL(VALUES(unionid), we_customer.unionid),
- birthday=IFNULL(VALUES(birthday), we_customer.birthday),
- corp_name=IFNULL(VALUES(corp_name), we_customer.corp_name),
- `position`=IFNULL(VALUES(`position`), we_customer.position),
- is_open_chat=IFNULL(VALUES(is_open_chat), we_customer.is_open_chat),
- add_user_id=IFNULL(VALUES(add_user_id), we_customer.add_user_id),
- add_time=IFNULL(VALUES(add_time),we_customer.add_time),
- qq=IFNULL(VALUES(qq), we_customer.qq),
- email=IFNULL(VALUES(email), we_customer.email),
- address=IFNULL(VALUES(address), we_customer.address),
- phone=IFNULL(VALUES(phone), we_customer.phone),
- add_method=IFNULL(VALUES(add_method), we_customer.add_method),
- del_flag=IFNULL(VALUES(del_flag),we_customer.del_flag),
- `state`=IFNULL(VALUES(`state`),we_customer.state),
- create_by=IFNULL(VALUES(create_by),we_customer.create_by),
- create_by_id=IFNULL(VALUES(create_by_id),we_customer.create_by_id),
- update_by=IFNULL(VALUES(update_by),we_customer.update_by),
- update_by_id=IFNULL(VALUES(update_by_id),we_customer.update_by_id),
- update_time=IFNULL(VALUES(update_time),we_customer.update_time),
- other_descr=IFNULL(VALUES(other_descr),we_customer.other_descr),
- tag_ids=IFNULL(VALUES(tag_ids),we_customer.tag_ids),
- loss_time=IFNULL(VALUES(loss_time),we_customer.loss_time),
- del_flag_bei=IFNULL(VALUES(del_flag_bei),we_customer.del_flag_bei),
- del_flag_ba=IFNULL(VALUES(del_flag_ba),we_customer.del_flag_ba),
- remark_name=IFNULL(VALUES(remark_name),we_customer.remark_name);
- </insert>
- <select id="findCurrentTenantSysUser" resultType="com.linkwechat.common.core.domain.entity.SysUser">
- SELECT * FROM sys_user
- </select>
- <select id="findCurrentSysUserInfo" resultType="com.linkwechat.common.core.domain.entity.SysUser">
- SELECT * FROM sys_user where user_id=#{userId}
- </select>
- <select id="findSysUserInfoByWeUserId" resultType="com.linkwechat.common.core.domain.entity.SysUser">
- SELECT * FROM sys_user where we_user_id= #{weUserId}
- </select>
- <select id="getCustomerListByCondition" resultType="com.linkwechat.domain.WeCustomer">
- select distinct wc.external_userid,
- wc.add_user_id
- from we_customer wc
- left join sys_user su on wc.add_user_id = su.we_user_id and su.del_flag = 0
- left join sys_user_dept sud
- on sud.we_user_id = su.we_user_id and sud.del_flag = 0
- left join we_flower_customer_tag_rel wfctr
- on wfctr.external_userid = wc.external_userid and wfctr.del_flag = 0
- <where>
- <if test="userIds != null and userIds != ''">
- and su.we_user_id in
- <foreach collection="userIds.split(',')" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="deptIds != null and deptIds != ''">
- and sud.dept_id in
- <foreach collection="deptIds.split(',')" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="tagIds != null and tagIds != ''">
- <foreach item="tagId" index="index" collection="tagIds.split(',')">
- AND FIND_IN_SET(#{tagId},wfctr.tag_id)
- </foreach>
- </if>
- <if test="beginTime !=null and beginTime != ''">
- and date_format(wc.add_time,'%Y-%m-%d') >= #{beginTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and date_format(wc.add_time,'%Y-%m-%d') <= #{endTime}
- </if>
- <if test="stateList != null and stateList.size() > 0">
- and wc.state in
- <foreach item="state" collection="states" index="index" open="(" separator="," close=")">
- #{state}
- </foreach>
- </if>
- </where>
- and wc.del_flag = 0
- </select>
- <select id="findAllSysUser" resultType="com.linkwechat.common.core.domain.entity.SysUser">
- SELECT * FROM sys_user where del_flag=0
- </select>
- <delete id="deleteWeCustomer">
- DELETE from we_customer where external_userid=#{externalUserId} and add_user_id=#{userId}
- </delete>
- <delete id="removeById">
- DELETE from we_customer where id=#{userId}
- </delete>
- <select id="findWeCustomerListEuIds" resultType="java.lang.String">
- SELECT wcr.external_userid FROM we_customer wcr
- LEFT JOIN sys_user su on su.we_user_id=wcr.add_user_id
- <where>
- <if test="weCustomerList.name != null and weCustomerList.name !=''">
- AND CONCAT( IFNULL(wcr.customer_name,''),IFNULL(su.user_name,''))
- LIKE CONCAT('%',#{weCustomerList.name,jdbcType=VARCHAR},'%')
- </if>
- <if test="weCustomerList.customerType !=null">
- AND wcr.customer_type=#{weCustomerList.customerType}
- </if>
- <if test="weCustomerList.trackState !=null">
- AND wcr.track_state=#{weCustomerList.trackState}
- </if>
- <if test="weCustomerList.isFilterLossCustomer">
- AND wcr.track_state != 5
- </if>
- <if test="weCustomerList.addMethod !=null">
- AND wcr.add_method=#{weCustomerList.addMethod}
- </if>
- <if test="weCustomerList.tagIds !=null and weCustomerList.tagIds !=''">
- <foreach item="tagId" index="index" collection="weCustomerList.tagIds.split(',')">
- AND FIND_IN_SET(#{tagId},wcr.tag_ids)
- </foreach>
- </if>
- <if test="weCustomerList.beginTime !=null and weCustomerList.beginTime != '' and weCustomerList.endTime !='' and weCustomerList.endTime != null">
- AND date_format(wcr.add_time,'%Y-%m-%d') BETWEEN #{weCustomerList.beginTime} AND #{weCustomerList.endTime}
- </if>
- <if test="weCustomerList.firstUserId !=null">
- AND wcr.add_user_id in
- <foreach collection="weCustomerList.firstUserId.split(',')" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="weCustomerList.delFlag != null">
- AND wcr.del_flag = #{weCustomerList.delFlag}
- </if>
- </where>
- ORDER BY wcr.add_time desc
- </select>
- <select id="selectList1" resultType="com.linkwechat.domain.WeCustomer">
- SELECT * FROM we_customer
- where add_user_id = #{addUserId}
- and external_userid=#{externalUserid}
- </select>
- <select id="selectWeQrAdd" resultType="java.lang.String">
- SELECT we_user_id FROM we_qr_add a where a.del_flag=0
- </select>
- </mapper>
|