DistributionSellerMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.zhongzheng.modules.distribution.mapper.DistributionSellerMapper">
  6. <resultMap type="com.zhongzheng.modules.distribution.domain.DistributionSeller" id="DistributionSellerResult">
  7. <result property="sellerId" column="seller_id"/>
  8. <result property="realname" column="realname"/>
  9. <result property="status" column="status"/>
  10. <result property="createTime" column="create_time"/>
  11. <result property="updateTime" column="update_time"/>
  12. <result property="userAccount" column="user_account"/>
  13. <result property="gzhOpenId" column="gzh_open_id"/>
  14. <result property="unionId" column="union_id"/>
  15. <result property="parentId" column="parent_id"/>
  16. <result property="shareCode" column="share_code"/>
  17. <result property="registerFrom" column="register_from"/>
  18. </resultMap>
  19. <resultMap type="com.zhongzheng.modules.distribution.vo.DistributionSellerVo" id="DistributionSellerVoResult">
  20. <result property="sellerId" column="seller_id"/>
  21. <result property="realname" column="realname"/>
  22. <result property="status" column="status"/>
  23. <result property="userAccount" column="user_account"/>
  24. <result property="gzhOpenId" column="gzh_open_id"/>
  25. <result property="unionId" column="union_id"/>
  26. <result property="parentId" column="parent_id"/>
  27. <result property="shareCode" column="share_code"/>
  28. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  29. <result property="phonenumber" column="phonenumber"/>
  30. <result property="avatar" column="avatar"/>
  31. <result property="cash" column="cash"/>
  32. <result property="usedCash" column="used_cash"/>
  33. <result property="freezeCash" column="freeze_cash"/>
  34. <result property="parentName" column="parent_name"/>
  35. <result property="parentAccount" column="parent_account"/>
  36. <result property="promotionNum" column="promotion_num"/>
  37. </resultMap>
  38. <select id="getSellerListByTenant" parameterType="com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery" resultType="com.zhongzheng.modules.distribution.vo.DistributionSellerVo">
  39. SELECT ds.*,sr.realname,sr.user_account,t.tenant_name,
  40. (SELECT COUNT(*) FROM distribution_seller dr WHERE dr.parent_id = ds.seller_id) promotionNum
  41. FROM `distribution_seller` ds
  42. LEFT JOIN distribution_seller sr ON ds.parent_id = sr.seller_id
  43. LEFT JOIN sys_tenant t ON ds.tenant_id = t.tenant_id
  44. WHERE 1 = 1
  45. <if test="tenantId != null and tenantId != ''">
  46. AND ds.tenant_id = #{tenantId}
  47. </if>
  48. <if test="parentName != null and parentName != ''">
  49. AND sr.realname = #{parentName}
  50. </if>
  51. <if test="realname != null and realname != ''">
  52. AND ds.realname = #{realname}
  53. </if>
  54. </select>
  55. <select id="findList" parameterType="com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery" resultMap="DistributionSellerVoResult">
  56. SELECT
  57. s.realname,
  58. s.seller_id,
  59. s.user_account,
  60. s.share_code,
  61. s.gzh_open_id,
  62. u.id_card,
  63. u.phonenumber,
  64. u.`status`,
  65. ds.realname as parent_name,
  66. ds.user_account as parent_account,
  67. (SELECT count(*) from distribution_seller d where d.parent_id = s.seller_id) as promotion_num
  68. FROM
  69. distribution_seller s
  70. LEFT JOIN sys_user u ON s.seller_id = u.seller_id
  71. LEFT JOIN distribution_seller ds on s.parent_id = ds.seller_id
  72. WHERE
  73. 1=1
  74. <if test="realname != null and realname != ''">
  75. AND s.realname like concat('%', #{realname}, '%')
  76. </if>
  77. <if test="parentName != null and parentName != ''">
  78. AND ds.realname like concat('%', #{parentName}, '%')
  79. </if>
  80. ORDER BY
  81. s.seller_id DESC
  82. </select>
  83. <select id="findDetail" parameterType="Long" resultMap="DistributionSellerVoResult">
  84. SELECT
  85. s.realname,
  86. s.seller_id,
  87. s.user_account,
  88. s.share_code,
  89. s.gzh_open_id,
  90. u.id_card,
  91. u.phonenumber,
  92. u.`status`,
  93. u.avatar
  94. FROM
  95. distribution_seller s
  96. LEFT JOIN sys_user u ON s.seller_id = u.seller_id
  97. WHERE s.seller_id = #{sellerId}
  98. </select>
  99. </mapper>