BrokeragePostRatioMapper.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.dayou.mapper.BrokeragePostRatioMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.BrokeragePostRatio">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="created" property="created" />
  9. <result column="modified" property="modified" />
  10. <result column="post_id" property="postId" />
  11. <result column="brokerage_ratio" property="brokerageRatio" />
  12. </resultMap>
  13. <!-- 通用查询结果列 -->
  14. <sql id="Base_Column_List">
  15. id,
  16. deleted,
  17. created,
  18. modified,
  19. post_id, brokerage_ratio
  20. </sql>
  21. <select id="getLeadersRatio" parameterType="java.util.Set" resultType="com.dayou.bo.LeaderRatioBO">
  22. SELECT
  23. up.user_id,
  24. up.post_id,
  25. p.NAME AS postName,
  26. bpr.brokerage_ratio AS ratio,
  27. bpr.brokerage_rule as brokerageRule
  28. FROM
  29. user_post up
  30. LEFT JOIN brokerage_post_ratio bpr ON bpr.post_id = up.post_id
  31. LEFT JOIN post p ON p.id = up.post_id
  32. WHERE
  33. up.deleted = 0
  34. AND bpr.deleted = 0
  35. AND p.deleted = 0
  36. and up.user_id != #{userId}
  37. and up.post_id in
  38. <foreach collection="parentPostIds" index="index" item="item" open="(" close=")" separator=",">
  39. #{item}
  40. </foreach>
  41. </select>
  42. <select id="page" resultType="com.dayou.vo.PostRatioVO">
  43. SELECT
  44. r.id,
  45. p.id AS postId,
  46. p.NAME AS postName,
  47. d.NAME AS departmentName,
  48. r.brokerage_ratio,
  49. r.brokerage_rule
  50. FROM
  51. post p
  52. LEFT JOIN department d ON p.department_id = d.id
  53. LEFT JOIN brokerage_post_ratio r ON r.post_id = p.id
  54. WHERE
  55. p.deleted = 0
  56. AND d.deleted = 0
  57. <if test="ratio!=null and ratio.departmentId!=null">
  58. and d.id = #{ratio.departmentId}
  59. </if>
  60. ORDER BY
  61. r.id DESC;
  62. </select>
  63. <select id="getLeaderRatioBO" parameterType="java.util.Set" resultType="com.dayou.bo.LeaderRatioBO">
  64. SELECT
  65. up.user_id,
  66. up.post_id,
  67. p.NAME AS postName,
  68. bpr.brokerage_ratio AS ratio,
  69. bpr.brokerage_rule AS brokerageRule
  70. FROM
  71. user_post up
  72. left join brokerage_post_ratio bpr on bpr.post_id = up.post_id
  73. left join post p on p.id = up.post_id
  74. where
  75. up.deleted = 0
  76. AND bpr.deleted = 0
  77. AND p.deleted = 0
  78. and up.user_id in (
  79. <foreach collection="leaderIds" index="index" item="item" separator=",">
  80. #{item}
  81. </foreach>
  82. )
  83. </select>
  84. <select id="marketManagerRatioBO" resultType="com.dayou.bo.LeaderRatioBO">
  85. SELECT
  86. up.user_id,
  87. up.post_id,
  88. p.NAME AS postName,
  89. bpr.brokerage_ratio AS ratio,
  90. bpr.brokerage_rule AS brokerageRule
  91. FROM
  92. user_post up
  93. left join brokerage_post_ratio bpr on bpr.post_id = up.post_id
  94. left join post p on p.id = up.post_id
  95. where
  96. up.deleted = 0
  97. AND bpr.deleted = 0
  98. AND p.deleted = 0
  99. and p.name = '市场部经理'
  100. </select>
  101. </mapper>