152 lines
7.6 KiB
XML
152 lines
7.6 KiB
XML
<?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.stdiet.custom.mapper.SysWxSaleAccountMapper">
|
|
|
|
<resultMap type="SysWxSaleAccount" id="SysWxSaleAccountResult">
|
|
<result property="id" column="id"/>
|
|
<result property="wxNickName" column="wx_nick_name"/>
|
|
<result property="wxAccount" column="wx_account"/>
|
|
<result property="wxPhone" column="wx_phone"/>
|
|
<result property="wxCodeUrl" column="wx_code_url"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="wxType" column="wx_type"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="status" column="status"/>
|
|
<result property="useCount" column="use_count"/>
|
|
|
|
<!-- 销售 -->
|
|
<result property="saleName" column="sale_name"></result>
|
|
</resultMap>
|
|
|
|
<sql id="selectSysWxSaleAccountVo">
|
|
select id, wx_nick_name, wx_account, wx_phone, wx_code_url, remark, wx_type, create_time, create_by, update_time, update_by, del_flag, status, use_count from sys_wx_sale_account
|
|
</sql>
|
|
|
|
<select id="selectSysWxSaleAccountList" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
|
|
<include refid="selectSysWxSaleAccountVo"/>
|
|
where del_flag = 0
|
|
<if test="wxNickName != null and wxNickName != ''">and wx_nick_name like concat('%', #{wxNickName}, '%')</if>
|
|
<if test="wxAccount != null and wxAccount != ''">and wx_account like concat('%', #{wxAccount}, '%')</if>
|
|
<if test="wxPhone != null and wxPhone != ''">and wx_phone like concat('%', #{wxPhone}, '%')</if>
|
|
<if test="status != null">and status = #{status}</if>
|
|
order by id desc
|
|
</select>
|
|
|
|
<select id="selectSysWxSaleAccountById" parameterType="Long" resultMap="SysWxSaleAccountResult">
|
|
<include refid="selectSysWxSaleAccountVo"/>
|
|
where id = #{id} and del_flag = 0
|
|
</select>
|
|
|
|
<insert id="insertSysWxSaleAccount" parameterType="SysWxSaleAccount" useGeneratedKeys="true" keyProperty="id">
|
|
insert into sys_wx_sale_account
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="wxNickName != null">wx_nick_name,</if>
|
|
<if test="wxAccount != null">wx_account,</if>
|
|
<if test="wxPhone != null">wx_phone,</if>
|
|
<if test="wxCodeUrl != null">wx_code_url,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="wxType != null">wx_type,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="wxNickName != null">#{wxNickName},</if>
|
|
<if test="wxAccount != null">#{wxAccount},</if>
|
|
<if test="wxPhone != null">#{wxPhone},</if>
|
|
<if test="wxCodeUrl != null">#{wxCodeUrl},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="wxType != null">#{wxType},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateSysWxSaleAccount" parameterType="SysWxSaleAccount">
|
|
update sys_wx_sale_account
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="wxNickName != null">wx_nick_name = #{wxNickName},</if>
|
|
<if test="wxAccount != null">wx_account = #{wxAccount},</if>
|
|
<if test="wxPhone != null">wx_phone = #{wxPhone},</if>
|
|
<if test="wxCodeUrl != null">wx_code_url = #{wxCodeUrl},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="wxType != null">wx_type = #{wxType},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="useCount != null">use_count = #{useCount},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="deleteSysWxSaleAccountById" parameterType="Long">
|
|
update sys_wx_sale_account set del_flag = 1 where id = #{id}
|
|
</update>
|
|
|
|
<update id="deleteSysWxSaleAccountByIds" parameterType="String">
|
|
update sys_wx_sale_account set del_flag = 1 where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="selectWxAccountByAccountOrPhone" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
|
|
<include refid="selectSysWxSaleAccountVo"/>
|
|
where del_flag = 0
|
|
<if test="wxAccount != null and wxAccount != ''">and wx_account = #{wxAccount}</if>
|
|
<if test="wxPhone != null and wxPhone != ''">and wx_phone = #{wxPhone}</if>
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="selectWxAdId" resultType="String" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
|
|
SELECT * FROM sys_wx_sale_account WHERE status = 0 ORDER BY use_count ASC LIMIT 1
|
|
</select>
|
|
|
|
<insert id="insertWxAdLog" parameterType="SysWxAdLog" useGeneratedKeys="true" keyProperty="id">
|
|
insert into sys_wx_ad_logs
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">user_id,</if>
|
|
<if test="ip != null">ip,</if>
|
|
<if test="userAgent != null">user_agent,</if>
|
|
<if test="channelId != null">channel_id,</if>
|
|
<if test="wxId != null">wx_id,</if>
|
|
<if test="type != null">type,</if>
|
|
<if test="date != null">date,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">#{userId},</if>
|
|
<if test="ip != null">#{ip},</if>
|
|
<if test="userAgent != null">#{userAgent},</if>
|
|
<if test="channelId != null">#{channelId},</if>
|
|
<if test="wxId != null">#{wxId},</if>
|
|
<if test="type != null">#{type},</if>
|
|
<if test="date != null">#{date},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<!-- 查询可以接粉的微信号以及对应销售,用于导粉记录管理 -->
|
|
<select id="getWxAccountAndSale" parameterType="SysWxSaleAccount" resultMap="SysWxSaleAccountResult">
|
|
select wa.id, wa.wx_account, su.nick_name as sale_name
|
|
from sys_wx_sale_account wa
|
|
left join sys_wx_distribution swd on wa.id = swd.wechat_account and swd.del_flag = 0
|
|
LEFT JOIN sys_user su ON su.user_id = swd.user_id AND su.del_flag = 0
|
|
where wa.del_flag = 0 and wa.status = 0
|
|
<if test="wxAccount != null and wxAccount != ''">and wa.wx_account like concat('%', #{wxAccount}, '%')</if>
|
|
order by wa.id desc
|
|
</select>
|
|
|
|
</mapper> |