123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- <?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.fs.qw.mapper.QwExternalContactMapper">
- <resultMap type="QwExternalContact" id="QwExternalContactResult">
- <result property="id" column="id" />
- <result property="userId" column="user_id" />
- <result property="corpId" column="corp_id" />
- <result property="externalUserId" column="external_user_id" />
- <result property="name" column="name" />
- <result property="avatar" column="avatar" />
- <result property="type" column="type" />
- <result property="gender" column="gender" />
- <result property="remark" column="remark" />
- <result property="description" column="description" />
- <result property="tagIds" column="tag_ids" />
- <result property="remarkMobiles" column="remark_mobiles" />
- <result property="remarkCorpName" column="remark_corp_name" />
- <result property="addWay" column="add_way" />
- <result property="operUserid" column="oper_userid" />
- <result property="companyId" column="company_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="customerId" column="customer_id" />
- <result property="transferStatus" column="transfer_status" />
- <result property="status" column="status" />
- <result property="createTime" column="create_time" />
- <result property="transferTime" column="transfer_time" />
- <result property="transferNum" column="transfer_num" />
- <result property="lossTime" column="loss_time" />
- <result property="delTime" column="del_time" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="state" column="state" />
- <result property="wayId" column="way_id" />
- <result property="stageStatus" column="stage_status" />
- <result property="fsUserId" column="fs_user_id" />
- <result property="openId" column="open_id" />
- <result property="unionid" column="unionid" />
- <result property="isInteract" column="is_interact" />
- <result property="level" column="level" />
- <result property="leveType" column="level_type" />
- <result property="firstTime" column="first_time" />
- <result property="lastWatchTime" column="last_watch_time" />
- </resultMap>
- <sql id="selectQwExternalContactVo">
- select id,qw_user_id,state,way_id,stage_status,first_time,open_id,is_interact,level, unionid, user_id,transfer_time,loss_time,del_time,transfer_num, external_user_id,transfer_status,status,create_time, name, avatar, type, gender, remark, description, tag_ids, remark_mobiles, remark_corp_name, add_way, oper_userid, corp_id, company_id, company_user_id, customer_id, fs_user_id from qw_external_contact
- </sql>
- <select id="selectQwExternalContactList" parameterType="QwExternalContact" resultMap="QwExternalContactResult">
- <include refid="selectQwExternalContactVo"/>
- <where>
- <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
- <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
- <if test="externalUserId != null and externalUserId != ''"> and external_user_id = #{externalUserId}</if>
- <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
- <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
- <if test="type != null "> and type = #{type}</if>
- <if test="gender != null "> and gender = #{gender}</if>
- <if test="description != null and description != ''"> and description = #{description}</if>
- <if test="tagIds != null and tagIds != ''"> and tag_ids = #{tagIds}</if>
- <if test="remarkMobiles != null and remarkMobiles != ''"> and remark_mobiles = #{remarkMobiles}</if>
- <if test="remarkCorpName != null and remarkCorpName != ''"> and remark_corp_name like concat('%', #{remarkCorpName}, '%')</if>
- <if test="addWay != null "> and add_way = #{addWay}</if>
- <if test="operUserid != null and operUserid != ''"> and oper_userid = #{operUserid}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="customerId != null "> and customer_id = #{customerId}</if>
- <if test="fsUserId != null "> and fs_user_id = #{fsUserId}</if>
- <if test="unionid != null "> and unionid = #{unionid}</if>
- </where>
- </select>
- <select id="selectAllQwJoinAdClickLog" resultType="com.fs.qw.result.QwExternalContactVo">
- select a.*,MAX(b.url) url,MAX(b.vid) vid,MAX(b.aid) aid,MAX(b.account_id) accountId from qw_external_contact a
- inner join ad_html_click_log b on a.state = b.vid
- where a.state is not null and b.type = #{type}
- <if test="type == 0">
- and b.click_type = 67 and (upload_add_wx_status = 0 or upload_register_status = 0 or upload_finished_status = 0)
- </if>
- <if test="type == 1">
- and b.click_type = 'wechat' and upload_add_wx_status = 0
- </if>
- group by a.id
- </select>
- <select id="selectQwExternalContactListVOByIds" resultType="com.fs.qw.param.QwExternalContactVOTime">
- select id,tag_ids,remark,create_time,fs_user_id,avatar from qw_external_contact
- where id in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="selectAllFormAd" resultType="com.fs.qw.result.QwExternalContactLogVo">
- select a.*
- ,user.nick_name
- ,b.aid,b.pid,b.uid,b.userid accountId,b.comb_id,b.create_time as `time`
- ,creative.creative_feed_name
- ,plan.campaign_feed_name
- ,unit.adgroup_feed_name
- ,account.account_name
- ,info.sex,info.age,info.address
- from qw_external_contact a
- left join qw_external_contact_info info on a.id = info.external_contact_id
- inner join ad_html_click_log b on a.state = b.vid
- left join bd_creative creative on b.aid = creative.creative_feed_id
- left join bd_plan plan on b.pid = plan.campaign_feed_id
- left join bd_unit unit on b.uid = unit.adgroup_feed_id
- <if test="accountId == null and userId == null">left join </if>
- <if test="accountId != null || userId != null">inner join </if>
- bd_account account on b.userid = account.account_id
- left join company_user user on account.user_id = user.user_id
- where a.state is not null and b.click_type = 67
- AND date_format(b.create_time,'%Y-%m-%d %h:%i:%s') >= #{start}
- and date_format(b.create_time,'%Y-%m-%d %h:%i:%s') <= #{end}
- <if test="accountId != null">
- and account.account_id = #{accountId}
- </if>
- <if test="userId != null">
- and account.user_id = #{userId}
- </if>
- <if test="aid != null">
- and b.aid = #{aid}
- </if>
- <if test="pid != null">
- and b.pid = #{pid}
- </if>
- <if test="uid != null">
- and b.uid = #{uid}
- </if>
- group by a.id
- </select>
- <select id="selectQwExternalContactById" parameterType="Long" resultMap="QwExternalContactResult">
- <include refid="selectQwExternalContactVo"/>
- where id = #{id}
- </select>
- <update id="batchUpdateQwExternalContact" parameterType="map">
- UPDATE qw_external_contact
- SET
- level = CASE id
- <foreach collection="list" item="item">
- WHEN #{item.id} THEN #{item.level}
- </foreach>
- ELSE level
- END,
- level_type = CASE id
- <foreach collection="list" item="item">
- WHEN #{item.id} THEN #{item.levelType}
- </foreach>
- ELSE level_type
- END,
- last_watch_time = CASE id
- <foreach collection="list" item="item">
- WHEN #{item.id} THEN #{item.lastWatchTime}
- </foreach>
- ELSE last_watch_time
- END
- WHERE id IN
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item.id}
- </foreach>
- </update>
- <update id="batchUpdateQwExternalContactStatus" parameterType="map">
- UPDATE qw_external_contact
- SET status = 4
- WHERE user_id = #{qwUserId}
- AND corp_id = #{corpId}
- AND external_user_id IN
- <foreach collection="notInExternalUseridList" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </update>
- <insert id="insertQwExternalContact" parameterType="QwExternalContact" useGeneratedKeys="true" keyProperty="id" >
- insert into qw_external_contact
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">id,</if>
- <if test="userId != null">user_id,</if>
- <if test="externalUserId != null">external_user_id,</if>
- <if test="name != null">name,</if>
- <if test="avatar != null">avatar,</if>
- <if test="type != null">type,</if>
- <if test="gender != null">gender,</if>
- <if test="remark != null">remark,</if>
- <if test="description != null">description,</if>
- <if test="tagIds != null">tag_ids,</if>
- <if test="remarkMobiles != null">remark_mobiles,</if>
- <if test="remarkCorpName != null">remark_corp_name,</if>
- <if test="addWay != null">add_way,</if>
- <if test="operUserid != null">oper_userid,</if>
- <if test="corpId != null">corp_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="customerId != null">customer_id,</if>
- <if test="transferStatus != null">transfer_status,</if>
- <if test="status != null">status,</if>
- <if test="createTime != null">create_time,</if>
- <if test="transferTime != null">transfer_time,</if>
- <if test="transferNum != null">transfer_num,</if>
- <if test="lossTime != null">loss_time,</if>
- <if test="delTime != null">del_time,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="state != null">`state`,</if>
- <if test="wayId != null">way_id,</if>
- <if test="stageStatus != null">stage_status,</if>
- <if test="fsUserId != null">fs_user_id,</if>
- <if test="openId != null">open_id,</if>
- <if test="unionid != null">unionid,</if>
- <if test="isInteract != null">is_interact,</if>
- <if test="level != null">level,</if>
- <if test="levelType != null">level_type,</if>
- <if test="firstTime != null">first_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">#{id},</if>
- <if test="userId != null">#{userId},</if>
- <if test="externalUserId != null">#{externalUserId},</if>
- <if test="name != null">#{name},</if>
- <if test="avatar != null">#{avatar},</if>
- <if test="type != null">#{type},</if>
- <if test="gender != null">#{gender},</if>
- <if test="remark != null">#{remark},</if>
- <if test="description != null">#{description},</if>
- <if test="tagIds != null">#{tagIds},</if>
- <if test="remarkMobiles != null">#{remarkMobiles},</if>
- <if test="remarkCorpName != null">#{remarkCorpName},</if>
- <if test="addWay != null">#{addWay},</if>
- <if test="operUserid != null">#{operUserid},</if>
- <if test="corpId != null">#{corpId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="customerId != null">#{customerId},</if>
- <if test="transferStatus != null">#{transferStatus},</if>
- <if test="status != null">#{status},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="transferTime != null">#{transferTime},</if>
- <if test="transferNum != null">#{transferNum},</if>
- <if test="lossTime != null">#{lossTime},</if>
- <if test="delTime != null">#{delTime},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="state != null">#{state},</if>
- <if test="wayId != null">#{wayId},</if>
- <if test="stageStatus != null">#{stageStatus},</if>
- <if test="fsUserId != null">#{fsUserId},</if>
- <if test="openId != null">#{openId},</if>
- <if test="unionid != null">#{unionid},</if>
- <if test="isInteract != null">#{isInteract},</if>
- <if test="level != null">#{level},</if>
- <if test="levelType != null">#{levelType},</if>
- <if test="firstTime != null">#{firstTime},</if>
- </trim>
- </insert>
- <update id="updateQwExternalContact" parameterType="QwExternalContact">
- update qw_external_contact
- <trim prefix="SET" suffixOverrides=",">
- <if test="userId != null">user_id = #{userId},</if>
- <if test="corpId != null">corp_id = #{corpId},</if>
- <if test="externalUserId != null">external_user_id = #{externalUserId},</if>
- <if test="name != null">name = #{name},</if>
- <if test="avatar != null">avatar = #{avatar},</if>
- <if test="type != null">type = #{type},</if>
- <if test="gender != null">gender = #{gender},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="description != null">description = #{description},</if>
- <if test="tagIds != null">tag_ids = #{tagIds},</if>
- <if test="remarkMobiles != null">remark_mobiles = #{remarkMobiles},</if>
- <if test="remarkCorpName != null">remark_corp_name = #{remarkCorpName},</if>
- <if test="addWay != null">add_way = #{addWay},</if>
- <if test="operUserid != null">oper_userid = #{operUserid},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="customerId != null">customer_id = #{customerId},</if>
- <if test="transferStatus != null">transfer_status = #{transferStatus},</if>
- <if test="status != null">status = #{status},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="transferTime != null">transfer_time = #{transferTime},</if>
- <if test="transferNum != null">transfer_num = #{transferNum},</if>
- <if test="lossTime != null">loss_time = #{lossTime},</if>
- <if test="delTime != null">del_time = #{delTime},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="state != null">`state` = #{state},</if>
- <if test="wayId != null">way_id = #{wayId},</if>
- <if test="stageStatus != null">stage_status = #{stageStatus},</if>
- <if test="fsUserId != null">fs_user_id = #{fsUserId},</if>
- <if test="openId != null">open_id = #{openId},</if>
- <if test="unionid != null">unionid = #{unionid},</if>
- <if test="isInteract != null">is_interact = #{isInteract},</if>
- <if test="level != null">level = #{level},</if>
- <if test="levelType != null">level_type = #{levelType},</if>
- <if test="firstTime != null">first_time = #{firstTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteQwExternalContactById" parameterType="Long">
- delete from qw_external_contact where id = #{id}
- </delete>
- <delete id="deleteQwExternalContactByIds" parameterType="String">
- delete from qw_external_contact where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="selectQwExternalContactListVOByUserIds" resultType="com.fs.qw.param.QwExternalContactVOTime">
- select id,tag_ids,remark,create_time,external_user_id from qw_external_contact
- where external_user_id in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- group by external_user_id
- </select>
- <select id="selectByGroupUser" resultType="com.fs.qw.vo.GroupUserExternalVo">
- select id,user_id,external_user_id from qw_external_contact where external_user_id in
- <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
- GROUP BY user_id,external_user_id
- </select>
- </mapper>
|