UserInfoMapper.xml 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.miaxis.user.mapper.UserInfoMapper">
  6. <resultMap type="UserInfo" id="UserInfoResult">
  7. <result property="id" column="id" />
  8. <result property="phone" column="phone" />
  9. <result property="wechar" column="wechar" />
  10. <result property="headImage" column="head_image" />
  11. <result property="nickName" column="nick_name" />
  12. <result property="openid" column="openid" />
  13. <result property="createTime" column="create_time" />
  14. <result property="updateTime" column="update_time" />
  15. <result property="status" column="status" />
  16. <result property="isVip" column="is_vip" />
  17. <result property="unionId" column="union_id" />
  18. </resultMap>
  19. <sql id="selectUserInfoVo">
  20. select * from user_info
  21. </sql>
  22. <select id="selectUserInfoList" parameterType="UserInfo" resultMap="UserInfoResult">
  23. <include refid="selectUserInfoVo"/>
  24. <where>
  25. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  26. <if test="wechar != null and wechar != ''"> and wechar = #{wechar}</if>
  27. <if test="headImage != null and headImage != ''"> and head_image = #{headImage}</if>
  28. <if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
  29. <if test="openid != null and openid != ''"> and openid = #{openid}</if>
  30. <if test="status != null "> and status = #{status}</if>
  31. <if test="isVip != null "> and is_vip = #{isVip}</if>
  32. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  33. </where>
  34. </select>
  35. <select id="selectUserByParentOpenid" resultType="com.miaxis.common.core.domain.entity.UserInfo">
  36. SELECT
  37. u.openid,
  38. u.nick_name,
  39. u.head_image,
  40. u.create_time
  41. FROM
  42. user_info u
  43. LEFT JOIN wx_spread_relation sr ON sr.openid = u.openid
  44. WHERE sr.parent_openid = #{openid}
  45. ORDER BY u.create_time desc
  46. </select>
  47. <select id="selectUserByList" resultType="com.miaxis.common.core.domain.entity.UserInfo">
  48. SELECT
  49. u.openid,
  50. u.nick_name,
  51. u.head_image,
  52. u.create_time
  53. FROM
  54. user_info u
  55. LEFT JOIN wx_spread_relation sr ON sr.openid = u.openid
  56. WHERE sr.parent_openid in
  57. <foreach collection="list" item="openid" open="(" separator="," close=")">
  58. #{openid}
  59. </foreach>
  60. ORDER BY u.create_time desc
  61. </select>
  62. <select id="getUpUserInfo" resultType="com.miaxis.common.core.domain.entity.UserInfo">
  63. select * from user_info
  64. where openid = (select parent_openid from wx_spread_relation where openid = #{fromUserName})
  65. </select>
  66. <select id="getDownLevelPoints" resultType="com.miaxis.extension.vo.ExtensionIncomeVo">
  67. select openid,IFNULL(nick_name,'未知') as nick_name,IFNULL(head_image,'未知') as head_image,achievement,achievement_settled,
  68. (select count(1) from wx_spread_relation where parent_openid =t1.openid) as extension_count from user_info t1
  69. where openid in (select openid from wx_spread_relation where parent_openid = #{openid})
  70. </select>
  71. <select id="getPcDownLevelPoints" resultType="com.miaxis.extension.vo.ExtensionIncomeVo">
  72. select openid,IFNULL(nick_name,'未知') as nick_name,IFNULL(head_image,'未知') as head_image,achievement+achievement_settled as achievement_total,achievement,achievement_settled,
  73. (select count(1) from wx_spread_relation where parent_openid =t1.openid) as extension_count ,
  74. ( SELECT count( 1 ) FROM wx_spread_relation WHERE parent_openid = t1.openid ) AS extension_count ,
  75. IFNULL(( SELECT sum(payer_total) FROM wx_order WHERE openid = t1.openid and trade_state = 'SUCCESS' ),0) as cost_count
  76. from user_info t1
  77. where openid in (select openid from wx_spread_relation where parent_openid = #{openid})
  78. <if test="sortByParmName != null and sortByParmName != ''"> order by ${sortByParmName} desc</if>
  79. </select>
  80. </mapper>