ChannelUserRelMapper.xml 1.3 KB

123456789101112131415161718192021222324252627282930
  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="getChannelUserCnt" 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}, '.%')
  22. <if test="days != null and days != ''">
  23. 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')
  24. </if>
  25. </select>
  26. </mapper>