ChannelUserRelMapper.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.qs.mp.channel.mapper.ChannelUserRelMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.qs.mp.channel.domain.ChannelUserRel">
  6. <id column="id" property="id" />
  7. <result column="channel_id" property="channelId" />
  8. <result column="user_id" property="userId" />
  9. <result column="created_time" property="createdTime" />
  10. <result column="updated_time" property="updatedTime" />
  11. </resultMap>
  12. <!-- 通用查询结果列 -->
  13. <sql id="Base_Column_List">
  14. id, channel_id, user_id, created_time, updated_time
  15. </sql>
  16. <!-- 查询渠道及其子渠道经销商用户数总和 -->
  17. <select id="getChannelTotalUserCnt" resultType="integer">
  18. select count(t1.user_id) as userCnt
  19. from mp_channel_user_rel t1
  20. left join mp_channel t2 on t1.channel_id = t2.channel_id
  21. where (t2.channel_no like concat(#{channelNo}, '.%') or t2.channel_no = #{channelNo})
  22. </select>
  23. <!-- 根据渠道No查询渠道指定时间内新增的用户数量 -->
  24. <select id="getChannelNewUserCnt" resultType="integer">
  25. select count(t1.user_id) as userCnt
  26. from mp_channel_user_rel t1
  27. left join mp_channel t2 on t1.channel_id = t2.channel_id
  28. where (t2.channel_no like concat(#{channelNo}, '.%') or t2.channel_no = #{channelNo})
  29. <if test="days != null">
  30. <!-- AND date_format(t1.created_time,'%Y-%m-%d') between date_format(DATE_ADD(CURDATE(),INTERVAL #{days} DAY),'%Y-%m-%d') and date_format(CURDATE(),'%Y-%m-%d') -->
  31. AND t1.created_time between DATE_ADD(CURDATE(),INTERVAL #{days} DAY) and NOW()
  32. </if>
  33. </select>
  34. </mapper>