LoginMapper.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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.caimei365.user.mapper.LoginMapper">
  4. <select id="getLoginUserByUserId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  5. select u.userID as userId,
  6. u.clubID as clubId,
  7. u.shopID as shopId,
  8. u.serviceProviderId as serviceProviderId,
  9. u.userName as userName,
  10. u.mobile as mobile,
  11. u.bindMobile as bindMobile,
  12. u.email as email,
  13. u.userPermission as userPermission,
  14. u.userIdentity as userIdentity,
  15. u.password as password,
  16. u.clubStatus as clubStatus,
  17. u.manufacturerStatus as shopStatus
  18. from user u
  19. where u.userID = #{userId}
  20. limit 1
  21. </select>
  22. <select id="getLoginUserByMobileOrEmail" resultType="com.caimei365.user.model.vo.UserLoginVo">
  23. select u.userID as userId,
  24. u.clubID as clubId,
  25. u.shopID as shopId,
  26. u.serviceProviderId as serviceProviderId,
  27. u.userName as userName,
  28. u.mobile as mobile,
  29. u.bindMobile as bindMobile,
  30. u.email as email,
  31. u.userPermission as userPermission,
  32. u.userIdentity as userIdentity,
  33. u.password as password,
  34. u.clubStatus as clubStatus,
  35. u.manufacturerStatus as shopStatus,
  36. cu.id as operationId,
  37. cu.status as operationStatus,
  38. cu.mobile as operationMobile
  39. from user u
  40. left join cm_mall_operation_user cu on cu.userID = u.userID
  41. where (u.bindMobile = #{mobileOrEmail}
  42. or u.email = #{mobileOrEmail}
  43. or (cu.mobile = #{mobileOrEmail} and cu.delFlag != 1)
  44. ) and u.userIdentity in (1,2,3,4) and u.userOrganizeID = 0
  45. limit 1
  46. </select>
  47. <select id="getLoginUserByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
  48. select u.userID as userId,
  49. u.clubID as clubId,
  50. u.shopID as shopId,
  51. u.serviceProviderId as serviceProviderId,
  52. u.userName as userName,
  53. u.mobile as mobile,
  54. u.bindMobile as bindMobile,
  55. u.email as email,
  56. u.userPermission as userPermission,
  57. u.userIdentity as userIdentity,
  58. u.password as password,
  59. u.clubStatus as clubStatus,
  60. u.manufacturerStatus as shopStatus,
  61. cu.id as operationId,
  62. cu.status as operationStatus,
  63. cu.mobile as operationMobile
  64. from user u
  65. left join cm_mall_operation_user cu on cu.userID = u.userID
  66. where u.userOrganizeID = 0 and cu.delFlag != 1
  67. and (u.bindMobile = #{mobile} or cu.mobile = #{mobile} )
  68. and u.userIdentity in (1,2,3,4)
  69. limit 1
  70. </select>
  71. <select id="getServiceProviderUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  72. select s.serviceProviderId as serviceProviderId,
  73. s.userID as userId,
  74. u.userName as userName,
  75. u.mobile as mobile,
  76. u.bindMobile as bindMobile,
  77. u.email as email,
  78. u.userPermission as userPermission,
  79. u.userIdentity as userIdentity,
  80. u.password as password
  81. from serviceprovider s
  82. left join user u on s.userID = u.userID
  83. where s.openid = #{openId} and u.validFlag = 1
  84. limit 1
  85. </select>
  86. <select id="getServiceProviderByUserId" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
  87. select s.serviceProviderId as serviceProviderId,
  88. s.status as status,
  89. s.userID as userId
  90. from serviceprovider s
  91. where s.userID = #{userId}
  92. limit 1
  93. </select>
  94. <select id="getLoginUserByUnionId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  95. select u.userID as userId,
  96. u.clubID as clubId,
  97. u.shopID as shopId,
  98. u.serviceProviderId as serviceProviderId,
  99. u.userName as userName,
  100. u.mobile as mobile,
  101. u.bindMobile as bindMobile,
  102. u.email as email,
  103. u.userPermission as userPermission,
  104. u.userIdentity as userIdentity,
  105. u.password as password,
  106. u.clubStatus as clubStatus,
  107. u.manufacturerStatus as shopStatus,
  108. o.unionId as unionId,
  109. o.status as operationStatus,
  110. o.mobile as operationMobile,
  111. <if test="source=='www'">
  112. o.pcOpenid as openId
  113. </if>
  114. <if test="source=='crm'">
  115. o.crmOpenid as openId
  116. </if>
  117. <if test="source=='mini'">
  118. o.openid as openId
  119. </if>
  120. from user u
  121. left join cm_mall_operation_user o on o.userID = u.userID
  122. where (o.unionId = #{unionId} and o.delFlag = '0')
  123. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID = 0)
  124. limit 1
  125. </select>
  126. <select id="getLoginUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  127. select u.userID as userId,
  128. u.clubID as clubId,
  129. u.shopID as shopId,
  130. u.serviceProviderId as serviceProviderId,
  131. u.userName as userName,
  132. u.mobile as mobile,
  133. u.bindMobile as bindMobile,
  134. u.email as email,
  135. u.userPermission as userPermission,
  136. u.userIdentity as userIdentity,
  137. u.password as password,
  138. u.clubStatus as clubStatus,
  139. u.manufacturerStatus as shopStatus,
  140. o.unionId as unionId,
  141. o.status as operationStatus,
  142. o.mobile as operationMobile,
  143. <if test="source=='www'">
  144. o.pcOpenid as openId
  145. </if>
  146. <if test="source=='crm'">
  147. o.crmOpenid as openId
  148. </if>
  149. <if test="source=='mini'">
  150. o.openid as openId
  151. </if>
  152. from user u
  153. left join cm_mall_operation_user o on o.userID = u.userID
  154. where (
  155. <if test="source=='www'">
  156. o.pcOpenid = #{openId}
  157. </if>
  158. <if test="source=='crm'">
  159. o.crmOpenid = #{openId}
  160. </if>
  161. <if test="source=='mini'">
  162. o.openid = #{openId}
  163. </if>
  164. and o.delFlag = '0')
  165. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID = 0)
  166. limit 1
  167. </select>
  168. <update id="updateServiceProviderUnionId">
  169. update serviceprovider
  170. set unionId = #{unionId}
  171. where userID = #{userId}
  172. </update>
  173. <select id="getUserIdByOpenId" resultType="java.lang.Integer">
  174. select o.userID as userId
  175. from
  176. cm_mall_operation_user o
  177. where
  178. <if test="source=='www'">
  179. pcOpenid = #{openId}
  180. </if>
  181. <if test="source=='crm'">
  182. crmOpenid = #{openId}
  183. </if>
  184. <if test="source=='mini'">
  185. openid = #{openId}
  186. </if>
  187. and delFlag = '0'
  188. and userOrganizeID=0
  189. limit 1
  190. </select>
  191. <select id="getOperationUserByInvitationCode" resultType="com.caimei365.user.model.vo.UserLoginVo">
  192. SELECT
  193. cou.id as operationId,
  194. u.userID as userId,
  195. u.clubID as clubId,
  196. u.shopID as shopId,
  197. u.userName as userName,
  198. u.userIdentity,
  199. u.clubStatus as clubStatus,
  200. u.manufacturerStatus as shopStatus,
  201. cou.invitationCodeTime,
  202. cou.mobile as operationMobile,
  203. cou.status as operationStatus,
  204. cou.delFlag
  205. FROM
  206. cm_mall_operation_user cou
  207. LEFT JOIN user u ON u.userID = cou.userID
  208. WHERE
  209. cou.invitationCode = #{invitationCode}
  210. AND cou.userOrganizeID = 0
  211. AND u.userIdentity in (2,3,4)
  212. </select>
  213. <select id="getOperationUserByOperationId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  214. SELECT
  215. cou.id as operationId,
  216. u.userID as userId,
  217. u.clubID as clubId,
  218. u.shopID as shopId,
  219. u.userName as userName,
  220. u.userIdentity,
  221. u.clubStatus as clubStatus,
  222. u.manufacturerStatus as shopStatus,
  223. cou.invitationCodeTime,
  224. cou.mobile as operationMobile,
  225. cou.status as operationStatus,
  226. cou.delFlag
  227. FROM
  228. cm_mall_operation_user cou
  229. LEFT JOIN user u ON u.userID = cou.userID
  230. WHERE
  231. cou.id = #{operationId}
  232. AND cou.userOrganizeID = 0
  233. AND u.userIdentity in (2,3,4)
  234. </select>
  235. <select id="getClubCountByClubName" resultType="java.lang.Integer">
  236. SELECT
  237. count(*)
  238. FROM
  239. club
  240. WHERE
  241. name = #{name}
  242. AND status NOT IN (2, 20, 21, 3, 30)
  243. </select>
  244. <select id="getMaxClubId" resultType="java.lang.Integer">
  245. SELECT
  246. MAX(clubID)
  247. FROM club
  248. </select>
  249. <select id="getMaxUserId" resultType="java.lang.Integer">
  250. SELECT
  251. MAX(userID)
  252. FROM user
  253. </select>
  254. </mapper>