UserInviteMapper.xml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.chelvc.cloud.vehicle.server.dao.UserInviteMapper">
  4. <select id="teamList" resultType="com.chelvc.cloud.vehicle.api.dto.TeamDetailsDTO">
  5. SELECT
  6. i.user_id,
  7. target_id AS inviteUserId,
  8. SUM( r.reality_amount ) amount,
  9. r.source_type sourceType
  10. FROM
  11. user_invite i
  12. LEFT JOIN currency_record r ON i.user_id = r.user_id
  13. AND i.target_id = r.source_user_id
  14. AND r.type = 0
  15. AND i.type = r.source_type
  16. WHERE
  17. i.user_id = #{userId}
  18. <if test="type != null">
  19. and i.type = #{type}
  20. </if>
  21. GROUP BY
  22. i.id
  23. ORDER BY
  24. amount DESC
  25. limit #{pageNum}, #{pageSize}
  26. </select>
  27. <select id="teamTotalStatistics" resultType="com.chelvc.cloud.vehicle.api.dto.TeamDTO">
  28. SELECT
  29. count(i.id) total,
  30. sum(r.reality_amount) totalAmount
  31. FROM
  32. user_invite i
  33. LEFT JOIN currency_record r ON i.user_id = r.user_id
  34. AND i.target_id = r.source_user_id
  35. AND r.type = 0
  36. AND i.type = r.source_type
  37. WHERE
  38. i.user_id = #{userId}
  39. <if test="type != null">
  40. and i.type = #{type}
  41. </if>
  42. </select>
  43. </mapper>