ClubMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 authParty,createTime
  46. from cm_brand_auth where authUserId = #{authUserId} and delFlag = 0
  47. <if test="authParty != null and authParty != ''">
  48. and authParty like concat('%',#{authParty},'%')
  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.openId,
  60. cu.status
  61. from cm_brand_club_user cu
  62. left join cm_brand_auth a on cu.authId = a.id
  63. where cu.authUserId = #{authUserId}
  64. and cu.delFlag = 0
  65. and (a.id is null || a.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 authParty,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 r.authId as authId, count(*) as productCount
  86. from cm_brand_auth_product p left join cm_brand_product_relation r on p.id = r.productId
  87. where p.status = 1 group by r.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="authParty != null and authParty != ''">
  94. and a.authParty like concat('%',#{authParty},'%')
  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 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 and a.delFlag = 0
  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,a.authParty,a.logo
  115. from cm_brand_club_user cu
  116. left join cm_brand_auth a on cu.authId = a.id and a.delFlag = 0
  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. a.authImage,
  144. a.linkMan,
  145. a.linkMobile,
  146. a.medicalLicenseImage,
  147. a.firstClubType,
  148. a.secondClubType,
  149. a.empNum,
  150. concat(a.lng,',',a.lat) as lngAndLat,
  151. if(a.customFlag = 1,a.remarks,null) as remarks
  152. from cm_brand_auth a
  153. left join cm_brand_auth_user u on a.authUserId = u.authUserId
  154. left join province p on a.provinceId = p.provinceID
  155. left join city c on a.cityId = c.cityID
  156. left join town t on a.townId = t.townID
  157. where a.id = #{authId}
  158. and a.delFlag = 0
  159. and u.status = 1
  160. and a.status = 1
  161. and a.auditStatus = 1;
  162. </select>
  163. <select id="getDbPassword" resultType="java.lang.String">
  164. select password from cm_brand_club_user where id = #{clubUserId}
  165. </select>
  166. <select id="getWxStarClubList" resultType="com.caimei.model.vo.WxClubListVo">
  167. select id as authId, authParty as authParty,concat(ifnull(p.name,''),ifnull(c.name,''),ifnull(t.name,'')) as area,a.address,a.mobile,a.logo,
  168. 99999 as distance
  169. from cm_brand_auth a
  170. left join cm_brand_auth_user au on a.authUserId = au.authUserId
  171. left join province p on a.provinceId = p.provinceID
  172. left join city c on a.cityId = c.cityID
  173. left join town t on a.townId = t.townID
  174. left join (select r.authId as authId, count(*) as productCount
  175. from cm_brand_auth_product p left join cm_brand_product_relation r on p.id = r.productId
  176. where p.status = 1 group by r.authId) pc on a.id = pc.authId
  177. where au.authUserId = #{authUserId}
  178. and a.status = 1
  179. and a.auditStatus = 1
  180. and a.delFlag = 0
  181. and au.status = 1
  182. and a.starFlag = 1
  183. order by a.starNum is null,a.starnum,a.createTime desc
  184. </select>
  185. <update id="saveBindAuth">
  186. update cm_brand_club_user
  187. set authId = #{authId},
  188. name=#{authParty}
  189. where id = #{clubUserId} and authUserId=#{authUserId}
  190. </update>
  191. <select id="getUserInfoByToken" resultType="com.caimei.model.vo.WxClubUserVo">
  192. select cu.id as clubUserId, cu.authId as authId, cu.authUserId, cu.mobile, cu.status,a.authParty,a.logo
  193. from cm_brand_club_user cu
  194. left join cm_brand_auth a on cu.authId = a.id and a.delFlag = 0
  195. left join cm_brand_auth_user au on a.authUserId = au.authUserId
  196. where cu.delFlag = 0 and cu.id = #{clubUserId}
  197. </select>
  198. </mapper>