DistributionSellerMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 as parentName,sr.user_account,t.tenant_name,u.id_card,u.phonenumber,
  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_user u ON ds.seller_id = u.seller_id
  44. LEFT JOIN sys_tenant t ON ds.tenant_id = t.tenant_id
  45. WHERE 1 = 1
  46. <if test="tenantId != null and tenantId != ''">
  47. AND ds.tenant_id = #{tenantId}
  48. </if>
  49. <if test="parentName != null and parentName != ''">
  50. AND sr.realname = #{parentName}
  51. </if>
  52. <if test="realname != null and realname != ''">
  53. AND ds.realname = #{realname}
  54. </if>
  55. </select>
  56. <select id="findList" parameterType="com.zhongzheng.modules.top.distribution.bo.DistributionSellerQuery" resultMap="DistributionSellerVoResult">
  57. SELECT
  58. s.realname,
  59. s.seller_id,
  60. s.user_account,
  61. s.share_code,
  62. s.gzh_open_id,
  63. u.id_card,
  64. u.phonenumber,
  65. u.`status`,
  66. ds.realname as parent_name,
  67. ds.user_account as parent_account,
  68. (SELECT count(*) from distribution_seller d where d.parent_id = s.seller_id) as promotion_num
  69. FROM
  70. distribution_seller s
  71. LEFT JOIN sys_user u ON s.seller_id = u.seller_id
  72. LEFT JOIN distribution_seller ds on s.parent_id = ds.seller_id
  73. WHERE
  74. 1=1
  75. <if test="realname != null and realname != ''">
  76. AND s.realname like concat('%', #{realname}, '%')
  77. </if>
  78. <if test="parentName != null and parentName != ''">
  79. AND ds.realname like concat('%', #{parentName}, '%')
  80. </if>
  81. ORDER BY
  82. s.seller_id DESC
  83. </select>
  84. <select id="findDetail" parameterType="Long" resultMap="DistributionSellerVoResult">
  85. SELECT
  86. s.realname,
  87. s.seller_id,
  88. s.user_account,
  89. s.share_code,
  90. s.gzh_open_id,
  91. s.cash,
  92. s.used_cash,
  93. s.freeze_cash,
  94. u.id_card,
  95. u.phonenumber,
  96. u.`status`,
  97. u.avatar
  98. FROM
  99. distribution_seller s
  100. LEFT JOIN sys_user u ON s.seller_id = u.seller_id
  101. WHERE s.seller_id = #{sellerId}
  102. </select>
  103. </mapper>