You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.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.baiye.modules.scrm.mapper.LoginEquipmentMapper">
<sql id="Base_Alias_Column_List">
wa.username,
wa.nickname,
wa.city_info,
wa.login_type,
wa.header_url,
wa.wx_id,
wa.sex,
wa.status,
wa.we_chat_no,
wa.remark,
le.create_time,
le.update_time,
wa.user_id,
wa.packet_id,
le.id,
le.pit,
le.robot_id,
le.device_number,
le.expiration_time
</sql>
<select id="selectByPage" resultType="com.baiye.modules.scrm.vo.WeChatAccountVO">
SELECT
<include refid="Base_Alias_Column_List"/>
FROM
tb_login_equipment le
LEFT JOIN ( SELECT equipment_id, max( create_time ) AS min_binding_time FROM tb_wechat_equipment GROUP BY equipment_id ) min_binding ON le.id = min_binding.equipment_id
LEFT JOIN tb_wechat_equipment we ON le.id = we.equipment_id
AND we.create_time = min_binding.min_binding_time
LEFT JOIN tb_wechat_account wa ON wa.id = we.account_id
where le.user_id = #{userId}
<if test="username != null">
AND wa.username LIKE concat('%',#{username,jdbcType=VARCHAR},'%')
</if>
<if test="wxId != null">
AND wa.wx_id LIKE concat('%',#{wxId,jdbcType=VARCHAR},'%')
</if>
<if test="startTime != null">
and wa.create_time &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
and wa.create_time &lt;= #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="packetId != null">
and wa.packet_id = #{packetId,jdbcType=BIGINT}
</if>
order by le.id desc
</select>
<select id="queryByDate" resultType="com.baiye.modules.scrm.vo.WeChatAddFriendVo">
SELECT DATE_FORMAT(f.create_time, '%m-%d') dayStr
, count(1) as num
, add_friend_type
FROM tb_wechat_friend f
WHERE DATE_SUB(CURDATE(), INTERVAL #{dayNum} DAY) &lt;= date (f.create_time)
and f.robot_wx_id = #{wxId,jdbcType=VARCHAR}
and f.user_id = #{userId}
GROUP BY dayStr, add_friend_type
ORDER BY dayStr
</select>
<select id="queryByUserId" resultType="com.baiye.modules.scrm.vo.WeChatAccountVO">
SELECT
<include refid="Base_Alias_Column_List"/>
FROM
tb_login_equipment le left join
tb_wechat_equipment we on we.equipment_id = le.id
LEFT join tb_wechat_account wa on wa.id = we.account_id
where le.user_id = #{userId}
</select>
<select id="findEquipmentByAccountId" resultType="com.baiye.modules.scrm.vo.WeChatAccountVO">
SELECT
<include refid="Base_Alias_Column_List"/>
FROM
tb_login_equipment le left join
tb_wechat_equipment we on we.equipment_id = le.id
LEFT join tb_wechat_account wa on wa.id = we.account_id
where wa.wx_id = #{wxId}
</select>
<select id="queryByPacketId" resultType="com.baiye.modules.scrm.vo.WeChatAccountVO">
SELECT
<include refid="Base_Alias_Column_List"/>
FROM
tb_login_equipment le
LEFT JOIN ( SELECT equipment_id, max( create_time ) AS min_binding_time FROM tb_wechat_equipment GROUP BY equipment_id ) min_binding ON le.id = min_binding.equipment_id
LEFT JOIN tb_wechat_equipment we ON le.id = we.equipment_id
AND we.create_time = min_binding.min_binding_time
LEFT JOIN tb_wechat_account wa ON wa.id = we.account_id
where wa.packet_id = #{packetId,jdbcType=BIGINT}
order by le.id desc
</select>
</mapper>