LoginMapper.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.userName as userName,
  9. u.mobile as mobile,
  10. u.bindMobile as bindMobile,
  11. u.email as email,
  12. u.userPermission as userPermission,
  13. u.userIdentity as userIdentity,
  14. u.password as password
  15. from user u
  16. where u.userID = #{userId}
  17. limit 1
  18. </select>
  19. <select id="getLoginUserByMobileOrEmail" resultType="com.caimei365.user.model.vo.UserLoginVo">
  20. select u.userID as userId,
  21. u.clubID as clubId,
  22. u.shopID as shopId,
  23. u.userName as userName,
  24. u.mobile as mobile,
  25. u.bindMobile as bindMobile,
  26. u.email as email,
  27. u.userPermission as userPermission,
  28. u.userIdentity as userIdentity,
  29. u.password as password,
  30. case
  31. when u.userIdentity = 3 then u.manufacturerStatus
  32. when (u.userIdentity = 2 or u.userIdentity = 4) then u.clubStatus
  33. else 0
  34. end as status
  35. from user u
  36. left join cm_mall_operation_user cu on cu.userID = u.userID
  37. where (u.bindMobile = #{mobileOrEmail}
  38. or u.email = #{mobileOrEmail}
  39. or (cu.mobile = #{mobileOrEmail} and cu.delFlag != 1)
  40. ) and u.userIdentity in (1,2,3,4)
  41. limit 1
  42. </select>
  43. <select id="getOperationByMobile" resultType="com.caimei365.user.model.po.OperationPo">
  44. select o.userID as userId,
  45. o.mobile as mobile,
  46. o.clubID as clubId,
  47. o.shopID as shopId,
  48. o.unionId as unionId
  49. from cm_mall_operation_user o
  50. where o.mobile = #{mobile} and o.delFlag = '0'
  51. limit 1
  52. </select>
  53. <select id="getServiceProviderByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  54. select u.userID as userId,
  55. u.userName as userName,
  56. u.mobile as mobile,
  57. u.bindMobile as bindMobile,
  58. u.email as email,
  59. u.userPermission as userPermission,
  60. u.userIdentity as userIdentity,
  61. u.password as password
  62. from serviceprovider s
  63. left join user u on s.userID = u.userID
  64. where s.openid = #{openid} and u.validFlag = 1
  65. limit 1
  66. </select>
  67. <select id="getOperationUserByUnionId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  68. select o.userID as userId,
  69. o.mobile as mobile,
  70. o.clubID as clubId,
  71. o.shopID as shopId,
  72. o.unionId as unionId,
  73. <if test="source=='www'">
  74. o.pcOpenid as openId
  75. </if>
  76. <if test="source=='crm'">
  77. o.crmOpenid as openId
  78. </if>
  79. <if test="source=='mini'">
  80. o.openid as openId
  81. </if>
  82. from
  83. cm_mall_operation_user o
  84. where unionId = #{unionId} and delFlag = '0'
  85. and (userOrganizeID='2' or userOrganizeID is null)
  86. limit 1
  87. </select>
  88. <select id="getOperationUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  89. select o.userID as userId,
  90. o.mobile as mobile,
  91. o.clubID as clubId,
  92. o.shopID as shopId,
  93. o.unionId as unionId,
  94. <if test="source=='www'">
  95. o.pcOpenid as openId
  96. </if>
  97. <if test="source=='crm'">
  98. o.crmOpenid as openId
  99. </if>
  100. <if test="source=='mini'">
  101. o.openid as openId
  102. </if>
  103. from
  104. cm_mall_operation_user o
  105. where
  106. <if test="source=='www'">
  107. pcOpenid = #{openId}
  108. </if>
  109. <if test="source=='crm'">
  110. crmOpenid = #{openId}
  111. </if>
  112. <if test="source=='mini'">
  113. openid = #{openId}
  114. </if>
  115. and delFlag = '0'
  116. and (userOrganizeID='2' or userOrganizeID is null)
  117. limit 1
  118. </select>
  119. <update id="updateServiceProviderUnionId">
  120. update serviceprovider
  121. set unionId = #{unionId}
  122. where userID = #{userId}
  123. </update>
  124. <update id="updateOperationOpenId">
  125. update cm_mall_operation_user
  126. set openid = #{openId}
  127. where userID = #{userId}
  128. </update>
  129. <update id="updateOperationUnionId">
  130. update cm_mall_operation_user
  131. set unionId = #{unionId}
  132. where userID = #{userId}
  133. </update>
  134. <update id="updateOperationByInvitation">
  135. update cm_mall_operation_user
  136. set unionId = #{unionId},
  137. openId = #{openId},
  138. nickName = #{nickName},
  139. headimgurl = #{avatarUrl},
  140. status = #{status},
  141. <if test="clubId != null">
  142. clubId = #{clubId},
  143. shopId = null,
  144. </if>
  145. <if test="shopId != null">
  146. shopId = #{shopId},
  147. clubId = null,
  148. </if>
  149. userType = #{userType},
  150. where id = #{id}
  151. </update>
  152. <update id="updateOperationByUnbind">
  153. update cm_mall_operation_user
  154. set unionId = #{unionId},
  155. openId = #{openId},
  156. nickName = #{nickName},
  157. bindTime = #{bindTime},
  158. updateTime = #{updateTime},
  159. status = #{status},
  160. userType = #{userType},
  161. <if test="clubId != null">
  162. clubId = #{clubId},
  163. shopId = null,
  164. </if>
  165. <if test="shopId != null">
  166. shopId = #{shopId},
  167. clubId = null,
  168. </if>
  169. delFlag = #{delFlag}
  170. where id = #{id}
  171. </update>
  172. <select id="getUserIdByOpenId" resultType="java.lang.Integer">
  173. select o.userID as userId
  174. from
  175. cm_mall_operation_user o
  176. where
  177. <if test="source=='www'">
  178. pcOpenid = #{openId}
  179. </if>
  180. <if test="source=='crm'">
  181. crmOpenid = #{openId}
  182. </if>
  183. <if test="source=='mini'">
  184. openid = #{openId}
  185. </if>
  186. and delFlag = '0'
  187. and (userOrganizeID='2' or userOrganizeID is null)
  188. limit 1
  189. </select>
  190. <select id="getOperationUserByInvitationCode" resultType="com.caimei365.user.model.vo.UserLoginVo">
  191. SELECT
  192. cou.id as operationId,
  193. u.userID as userId,
  194. u.clubID as clubId,
  195. u.shopID as shopId,
  196. cou.invitationCodeTime,
  197. cou.status as operationStatus,
  198. cou.delFlag,
  199. u.userIdentity,
  200. case
  201. when u.userIdentity = 3 then u.manufacturerStatus
  202. when (u.userIdentity = 2 or u.userIdentity = 4) then u.clubStatus
  203. else 0
  204. end as status
  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 = '2' OR cou.userOrganizeID IS NULL)
  211. AND u.userIdentity in (2,3,4)
  212. </select>
  213. </mapper>