ClubMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.caimei.mapper.cmMapper.ClubMapper">
  4. <insert id="insertClubUser">
  5. insert into cm_brand_club_user (authUserId, authId, name, mobile, password, addTime, status, delFlag)
  6. values (#{authUserId}, #{authId}, #{name}, #{mobile}, #{password}, #{addTime}, #{status}, 0)
  7. </insert>
  8. <insert id="insertFeedback">
  9. insert into cm_brand_club_feedback(clubUserId, content, commitTime, handleStatus)
  10. values (#{clubUserId}, #{content}, NOW(), 0)
  11. </insert>
  12. <update id="updateClubUser">
  13. update cm_brand_club_user
  14. set mobile = #{mobile}
  15. where id = #{id}
  16. </update>
  17. <update id="deleteClubUser">
  18. update cm_brand_club_user set delFlag = 1 where id = #{clubUserId}
  19. </update>
  20. <update id="updatePassword">
  21. update cm_brand_club_user
  22. set password = #{password}
  23. where mobile = #{mobile}
  24. and authUserId = #{authUserId}
  25. </update>
  26. <update id="bindAuthId">
  27. update cm_brand_club_user set authId = #{authId}, name = (select DISTINCT authParty from cm_brand_auth where id = #{authId}) where id = #{clubUserId}
  28. </update>
  29. <update id="updateStatus">
  30. update cm_brand_club_user
  31. set status = #{status}
  32. where id = #{clubUserId}
  33. </update>
  34. <update id="updateClubUserPassword">
  35. update cm_brand_club_user
  36. set password=#{password}
  37. where id = #{clubUserId}
  38. </update>
  39. <update id="unbindAuthId">
  40. update cm_brand_club_user
  41. set authId = null, name = null
  42. where id = #{clubUserId}
  43. </update>
  44. <select id="getClubList" resultType="com.caimei.model.vo.ClubVo">
  45. select id as authId,authParty as clubName,createTime
  46. from cm_brand_auth where authUserId = #{authUserId}
  47. <if test="clubName != null and clubName != ''">
  48. and authParty like concat('%',#{clubName},'%')
  49. </if>
  50. order by createTime desc
  51. </select>
  52. <select id="getClubUserList" resultType="com.caimei.model.vo.ClubUserVo">
  53. select cu.id as clubUserId,
  54. cu.authId,
  55. cu.name,
  56. cu.mobile,
  57. cu.addTime,
  58. cu.nickName,
  59. cu.mobile,
  60. cu.openId,
  61. cu.status
  62. from cm_brand_club_user cu
  63. left join cm_brand_auth a on cu.authId = a.id
  64. where cu.authUserId = #{authUserId}
  65. and cu.delFlag = 0
  66. <if test="name != null and name != ''">
  67. and cu.name like concat('%',#{name},'%')
  68. </if>
  69. <if test="mobile != null and mobile != ''">
  70. and cu.mobile like concat('%',#{mobile},'%')
  71. </if>
  72. <if test="status != null">
  73. and cu.status = #{status}
  74. </if>
  75. order by cu.addTime desc
  76. </select>
  77. <select id="getWxClubList" resultType="com.caimei.model.vo.WxClubListVo">
  78. select id as authId, authParty as clubName,concat(ifnull(p.name,''),ifnull(c.name,''),ifnull(t.name,'')) as area,a.address,a.mobile,a.logo,
  79. ifnull(round(st_distance(point(a.lng,a.lat),point(#{lng},#{lat}))*111195/1000,2),99999) as distance
  80. from cm_brand_auth a
  81. left join cm_brand_auth_user au on a.authUserId = au.authUserId
  82. left join province p on a.provinceId = p.provinceID
  83. left join city c on a.cityId = c.cityID
  84. left join town t on a.townId = t.townID
  85. left join (select cbap.authId as authId, count(*) as productCount
  86. from cm_brand_auth_product cbap where cbap.status = 1
  87. group by cbap.authId) pc on a.id = pc.authId
  88. where au.authUserId = #{authUserId}
  89. and a.status = 1
  90. and a.auditStatus = 1
  91. and a.delFlag = 0
  92. and au.status = 1
  93. <if test="clubName != null and clubName != ''">
  94. and a.authParty like concat('%',#{clubName},'%')
  95. </if>
  96. <if test="provinceId != null">
  97. and a.provinceId = #{provinceId}
  98. </if>
  99. <if test="cityId != null">
  100. and a.cityId = #{cityId}
  101. </if>
  102. <if test="townId != null">
  103. and a.townId = #{townId}
  104. </if>
  105. order by pc.productCount desc, distance
  106. </select>
  107. <select id="checkMobile" resultType="java.lang.Integer">
  108. select cu.id as clubUserId from cm_brand_club_user cu
  109. left join cm_brand_auth a on cu.authId = a.id
  110. left join cm_brand_auth_user au on a.authUserId = au.authUserId
  111. where cu.mobile = #{mobile} and au.appId = #{appId} and cu.delFlag = 0 limit 1
  112. </select>
  113. <select id="getWxClubUser" resultType="com.caimei.model.vo.WxClubUserVo">
  114. select cu.id as clubUserId, cu.authId as authId, cu.authUserId, cu.mobile, cu.status
  115. from cm_brand_club_user cu
  116. left join cm_brand_auth a on cu.authId = a.id
  117. left join cm_brand_auth_user au on a.authUserId = au.authUserId
  118. where cu.delFlag = 0
  119. <if test="mobile != null and mobile != ''">
  120. and cu.mobile = #{mobile}
  121. </if>
  122. <if test="appId != null and appId != ''">
  123. and au.appId = #{appId}
  124. </if>
  125. <if test="authUserId != null">
  126. and (au.authUserId = #{authUserId} or cu.authUserId = #{authUserId})
  127. </if>
  128. <if test="authId != null">
  129. and cu.authId = #{authId}
  130. </if>
  131. <if test="clubUserId != null">
  132. and cu.id = #{clubUserId}
  133. </if>
  134. limit 1
  135. </select>
  136. <select id="getClubDetails" resultType="com.caimei.model.vo.WxClubDetailsVo">
  137. select a.id as authId,
  138. a.authParty,
  139. concat(ifnull(p.name,''),ifnull(c.name,''),ifnull(t.name,'')) as area,
  140. a.address,
  141. a.mobile,
  142. a.logo,
  143. concat(a.lng,',',a.lat) as lngAndLat,
  144. if(a.customFlag = 1,a.remarks,null) as remarks
  145. from cm_brand_auth a
  146. left join cm_brand_auth_user u on a.authUserId = u.authUserId
  147. left join province p on a.provinceId = p.provinceID
  148. left join city c on a.cityId = c.cityID
  149. left join town t on a.townId = t.townID
  150. where a.id = #{authId}
  151. and u.status = 1
  152. and a.status = 1
  153. and a.auditStatus = 1;
  154. </select>
  155. <select id="getDbPassword" resultType="java.lang.String">
  156. select password from cm_brand_club_user where id = #{clubUserId}
  157. </select>
  158. </mapper>