LoginMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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.name as name,
  11. u.mobile as mobile,
  12. u.bindMobile as bindMobile,
  13. u.email as email,
  14. u.userIdentity as userIdentity,
  15. u.password as password,
  16. u.guideFlag as guideFlag,
  17. (select status from club where userId = u.userId limit 1) as clubStatus,
  18. u.manufacturerStatus as shopStatus
  19. from user u
  20. where u.userID = #{userId}
  21. limit 1
  22. </select>
  23. <select id="getLoginUserByMobileOrEmail" resultType="com.caimei365.user.model.vo.UserLoginVo">
  24. select u.userID as userId,
  25. u.userOrganizeID as organizeId,
  26. u.clubID as clubId,
  27. u.shopID as shopId,
  28. u.serviceProviderId as serviceProviderId,
  29. u.userName as userName,
  30. u.name as name,
  31. u.mobile as mobile,
  32. u.bindMobile as bindMobile,
  33. u.email as email,
  34. u.userIdentity as userIdentity,
  35. u.password as password,
  36. u.guideFlag as guideFlag,
  37. (select status from club where userId = u.userId limit 1) as clubStatus,
  38. u.manufacturerStatus as shopStatus,
  39. cu.id as operationId,
  40. cu.status as operationStatus,
  41. cu.mobile as operationMobile
  42. from user u
  43. left join cm_mall_operation_user cu on cu.userID = u.userID
  44. where (u.bindMobile = #{mobileOrEmail} or u.email = #{mobileOrEmail})
  45. and IF (u.userIdentity = 3, u.manufacturerStatus = 90, 1=1)
  46. and u.userIdentity in (1, 2, 3, 4)
  47. and u.userOrganizeID = 0
  48. union
  49. SELECT u.userID AS userId,
  50. u.userOrganizeID as organizeId,
  51. u.clubID AS clubId,
  52. u.shopID AS shopId,
  53. u.serviceProviderId AS serviceProviderId,
  54. u.userName AS userName,
  55. u.name AS NAME,
  56. u.mobile AS mobile,
  57. u.bindMobile AS bindMobile,
  58. u.email AS email,
  59. u.userIdentity AS userIdentity,
  60. u.password AS PASSWORD,
  61. u.guideFlag AS guideFlag,
  62. (select status from club where userId = u.userId limit 1) AS clubStatus,
  63. u.manufacturerStatus AS shopStatus,
  64. cu.id AS operationId,
  65. cu.status AS operationStatus,
  66. cu.mobile AS operationMobile
  67. FROM USER u
  68. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  69. WHERE
  70. cu.mobile = #{mobileOrEmail}
  71. and IF (u.userIdentity = 3, u.manufacturerStatus = 90, 1=1)
  72. and cu.delFlag != 1
  73. AND u.userIdentity IN (1, 2, 3, 4)
  74. AND u.userOrganizeID = 0
  75. limit 1
  76. </select>
  77. <select id="getLoginOrganizeUserByMobileOrEmail" resultType="com.caimei365.user.model.vo.UserLoginVo">
  78. select u.userID as userId,
  79. u.userOrganizeID as organizeId,
  80. u.clubID as clubId,
  81. u.shopID as shopId,
  82. u.serviceProviderId as serviceProviderId,
  83. u.userName as userName,
  84. u.name as name,
  85. (SELECT linkMan FROM club WHERE userId = u.userID) as clubLinkMan,
  86. u.mobile as mobile,
  87. u.bindMobile as bindMobile,
  88. u.email as email,
  89. u.userIdentity as userIdentity,
  90. u.password as password,
  91. u.guideFlag as guideFlag,
  92. (select status from club where userId = u.userId limit 1) as clubStatus,
  93. u.manufacturerStatus as shopStatus,
  94. u.serviceProviderStatus as serviceStatus,
  95. cu.id as operationId,
  96. cu.status as operationStatus,
  97. cu.mobile as operationMobile
  98. from user u
  99. left join cm_mall_operation_user cu on cu.userID = u.userID
  100. where (u.bindMobile = #{mobileOrEmail} or u.email = #{mobileOrEmail})
  101. and u.userIdentity in (1, 2, 3, 4)
  102. and u.userOrganizeID = 4
  103. union
  104. SELECT u.userID AS userId,
  105. u.userOrganizeID as organizeId,
  106. u.clubID AS clubId,
  107. u.shopID AS shopId,
  108. u.serviceProviderId AS serviceProviderId,
  109. u.userName AS userName,
  110. u.name AS NAME,
  111. ( SELECT linkMan FROM club WHERE userId = u.userID) as clubLinkMan,
  112. u.mobile AS mobile,
  113. u.bindMobile AS bindMobile,
  114. u.email AS email,
  115. u.userIdentity AS userIdentity,
  116. u.password AS PASSWORD,
  117. u.guideFlag AS guideFlag,
  118. (select status from club where userId = u.userId limit 1) AS clubStatus,
  119. u.manufacturerStatus AS shopStatus,
  120. u.serviceProviderStatus as serviceStatus,
  121. cu.id AS operationId,
  122. cu.status AS operationStatus,
  123. cu.mobile AS operationMobile
  124. FROM USER u
  125. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  126. WHERE
  127. cu.mobile = #{mobileOrEmail}
  128. and cu.delFlag != 1
  129. AND u.userIdentity IN (1, 2, 3, 4)
  130. AND u.userOrganizeID = 4
  131. limit 1
  132. </select>
  133. <select id="getOperationUser" resultType="java.lang.Integer">
  134. select id from cm_mall_operation_user where mobile = #{mobileOrEmail} and delFlag = 0 and userOrganizeID = 4 limit 1
  135. </select>
  136. <insert id="insertOperation">
  137. INSERT INTO cm_mall_operation_user (userOrganizeID, userType, userID, clubID, mobile, linkName, STATUS, unionId, bindTime, addTime, delFlag)
  138. values(#{organizeId}, #{userType}, #{userId}, #{clubId}, #{mobile}, #{linkName}, #{status}, #{unionId}, #{bindTime}, #{addTime}, #{delFlag})
  139. </insert>
  140. <select id="getLoginUserByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
  141. select u.userID as userId,
  142. u.clubID as clubId,
  143. u.shopID as shopId,
  144. u.serviceProviderId as serviceProviderId,
  145. u.userName as userName,
  146. u.name as name,
  147. u.mobile as mobile,
  148. u.bindMobile as bindMobile,
  149. u.email as email,
  150. u.userIdentity as userIdentity,
  151. u.password as password,
  152. u.guideFlag as guideFlag,
  153. u.manufacturerStatus as shopStatus,
  154. cu.id as operationId,
  155. (select status from club where userId = u.userId limit 1) as clubStatus,
  156. cu.mobile as operationMobile
  157. from user u
  158. left join cm_mall_operation_user cu on cu.userID = u.userID
  159. where (u.bindMobile = #{mobile} or (cu.mobile = #{mobile} and cu.delFlag != 1))
  160. and u.userOrganizeID = #{organizeId}
  161. and u.userIdentity in (1, 2, 3, 4)
  162. limit 1
  163. </select>
  164. <select id="getServiceProviderUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  165. select s.serviceProviderId as serviceProviderId,
  166. s.userID as userId,
  167. u.userName as userName,
  168. u.name as name,
  169. u.mobile as mobile,
  170. u.bindMobile as bindMobile,
  171. u.email as email,
  172. u.userIdentity as userIdentity,
  173. u.guideFlag as guideFlag,
  174. u.password as password
  175. from serviceprovider s
  176. left join user u on s.userID = u.userID
  177. where s.openid = #{openId}
  178. and s.organizeId = #{organizeId}
  179. and u.validFlag = 1
  180. limit 1
  181. </select>
  182. <select id="getServiceProviderByUserId" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
  183. select s.serviceProviderId as serviceProviderId,
  184. s.status as status,
  185. s.userID as userId
  186. from serviceprovider s
  187. where s.userID = #{userId}
  188. limit 1
  189. </select>
  190. <select id="getLoginUserByUnionId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  191. select u.userID as userId,
  192. u.clubID as clubId,
  193. u.shopID as shopId,
  194. u.serviceProviderId as serviceProviderId,
  195. u.userName as userName,u.name as name,
  196. u.mobile as mobile,
  197. u.bindMobile as bindMobile,
  198. u.email as email,
  199. u.userIdentity as userIdentity,
  200. u.password as password,
  201. u.guideFlag as guideFlag,
  202. (select status from club where userId = u.userId limit 1) as clubStatus,
  203. u.manufacturerStatus as shopStatus,
  204. o.unionId as unionId,
  205. o.status as operationStatus,
  206. o.mobile as operationMobile,
  207. <if test="source=='www'">
  208. o.pcOpenid as openId
  209. </if>
  210. <if test="source=='mini'">
  211. o.openid as openId
  212. </if>
  213. from user u
  214. left join cm_mall_operation_user o on o.userID = u.userID
  215. where (o.unionId = #{unionId} and o.delFlag = '0')
  216. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID = 0)
  217. limit 1
  218. </select>
  219. <select id="getOrganizeLoginUserByUnionId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  220. select u.userID as userId,
  221. u.clubID as clubId,
  222. u.shopID as shopId,
  223. u.serviceProviderId as serviceProviderId,
  224. u.userName as userName,u.name as name,
  225. u.mobile as mobile,
  226. u.bindMobile as bindMobile,
  227. u.email as email,
  228. u.userIdentity as userIdentity,
  229. u.serviceProviderID as serviceProviderId,
  230. u.password as password,
  231. u.guideFlag as guideFlag,
  232. c.status as clubStatus,
  233. u.manufacturerStatus as shopStatus,
  234. u.serviceProviderStatus as serviceStatus,
  235. o.unionId as unionId,
  236. o.status as operationStatus,
  237. o.mobile as operationMobile,
  238. c.headpic AS shopPhoto,
  239. <if test="source=='www'">
  240. o.pcOpenid as openId
  241. </if>
  242. <if test="source=='mini'">
  243. o.openid as openId
  244. </if>
  245. from user u
  246. left join cm_mall_operation_user o on o.userID = u.userID
  247. LEFT JOIN club c ON c.userID = u.userID
  248. where (o.unionId = #{unionId} and o.delFlag = '0')
  249. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID != 0)
  250. limit 1
  251. </select>
  252. <select id="getLoginUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  253. select u.userID as userId,
  254. u.clubID as clubId,
  255. u.shopID as shopId,
  256. u.serviceProviderId as serviceProviderId,
  257. u.userName as userName,u.name as name,
  258. u.mobile as mobile,
  259. u.bindMobile as bindMobile,
  260. u.email as email,
  261. u.userIdentity as userIdentity,
  262. u.password as password,
  263. u.guideFlag as guideFlag,
  264. (select status from club where userId = u.userId limit 1) as clubStatus,
  265. u.manufacturerStatus as shopStatus,
  266. o.unionId as unionId,
  267. o.status as operationStatus,
  268. o.mobile as operationMobile,
  269. <if test="source=='www'">
  270. o.pcOpenid as openId
  271. </if>
  272. <if test="source=='mini'">
  273. o.openid as openId
  274. </if>
  275. from user u
  276. left join cm_mall_operation_user o on o.userID = u.userID
  277. where (
  278. <if test="source=='www'">
  279. o.pcOpenid = #{openId}
  280. </if>
  281. <if test="source=='crm'">
  282. o.crmOpenid = #{openId}
  283. </if>
  284. <if test="source=='mini'">
  285. o.openid = #{openId}
  286. </if>
  287. and o.delFlag = '0')
  288. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID = 0)
  289. limit 1
  290. </select>
  291. <select id="getOrganizeLoginUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  292. select u.userID as userId,
  293. u.clubID as clubId,
  294. u.shopID as shopId,
  295. u.serviceProviderId as serviceProviderId,
  296. u.userName as userName,u.name as name,
  297. u.mobile as mobile,
  298. u.bindMobile as bindMobile,
  299. u.email as email,
  300. u.userIdentity as userIdentity,
  301. u.serviceProviderID as serviceProviderId,
  302. u.password as password,
  303. u.guideFlag as guideFlag,
  304. c.status as clubStatus,
  305. u.manufacturerStatus as shopStatus,
  306. o.unionId as unionId,
  307. o.status as operationStatus,
  308. o.mobile as operationMobile,
  309. c.headpic AS shopPhoto,
  310. <if test="source=='www'">
  311. o.pcOpenid as openId
  312. </if>
  313. <if test="source=='mini'">
  314. o.openid as openId
  315. </if>
  316. from user u
  317. left join cm_mall_operation_user o on o.userID = u.userID
  318. LEFT JOIN club c ON c.userID = u.userID
  319. where (
  320. <if test="source=='www'">
  321. o.pcOpenid = #{openId}
  322. </if>
  323. <if test="source=='crm'">
  324. o.crmOpenid = #{openId}
  325. </if>
  326. <if test="source=='mini'">
  327. o.openid = #{openId}
  328. </if>
  329. and o.delFlag = '0')
  330. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID != 0)
  331. limit 1
  332. </select>
  333. <update id="updateServiceProviderUnionId">
  334. update serviceprovider
  335. set unionId = #{unionId}
  336. where userID = #{userId}
  337. </update>
  338. <update id="updateLogin">
  339. update user
  340. set loginTime = now()
  341. where userID = #{userId}
  342. </update>
  343. <select id="getUserIdByOpenId" resultType="java.lang.Integer">
  344. select o.userID as userId
  345. from
  346. cm_mall_operation_user o
  347. where
  348. <if test="source=='www'">
  349. pcOpenid = #{openId}
  350. </if>
  351. <if test="source=='mini'">
  352. openid = #{openId}
  353. </if>
  354. and delFlag = '0'
  355. and userOrganizeID=0
  356. limit 1
  357. </select>
  358. <select id="getOperationUserByInvitationCode" resultType="com.caimei365.user.model.vo.UserLoginVo">
  359. SELECT cou.id as operationId,
  360. u.userID as userId,
  361. u.clubID as clubId,
  362. u.shopID as shopId,
  363. u.userName as userName,
  364. u.name as name,
  365. ifnull(cou.userOrganizeID, 0) as organizeId,
  366. u.userIdentity,
  367. u.guideFlag as guideFlag,
  368. (select status from club where userId = u.userId limit 1) as clubStatus,
  369. u.manufacturerStatus as shopStatus,
  370. cou.invitationCodeTime,
  371. cou.mobile as operationMobile,
  372. cou.status as operationStatus,
  373. cou.delFlag
  374. FROM cm_mall_operation_user cou
  375. LEFT JOIN user u ON u.userID = cou.userID
  376. WHERE cou.invitationCode = #{invitationCode}
  377. AND cou.userOrganizeID = #{organizeId}
  378. AND u.userIdentity in (2, 3, 4)
  379. </select>
  380. <select id="getOperationOrganizeUserByInvitationCode" resultType="com.caimei365.user.model.vo.UserLoginVo">
  381. SELECT cou.id as operationId,
  382. u.userID as userId,
  383. u.clubID as clubId,
  384. u.shopID as shopId,
  385. u.userName as userName,
  386. u.name as name,
  387. ifnull(cou.userOrganizeID, 0) as organizeId,
  388. u.userIdentity,
  389. u.guideFlag as guideFlag,
  390. (select status from club where userId = u.userId limit 1) as clubStatus,
  391. u.manufacturerStatus as shopStatus,
  392. cou.invitationCodeTime,
  393. cou.mobile as operationMobile,
  394. cou.status as operationStatus,
  395. cou.delFlag
  396. FROM cm_mall_operation_user cou
  397. LEFT JOIN user u ON u.userID = cou.userID
  398. WHERE cou.invitationCode = #{invitationCode}
  399. AND cou.userOrganizeID = #{organizeId}
  400. AND u.userIdentity in (2, 3, 4)
  401. </select>
  402. <select id="getOperationUserByOperationId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  403. SELECT cou.id as operationId,
  404. u.userID as userId,
  405. u.clubID as clubId,
  406. u.shopID as shopId,
  407. u.userName as userName,
  408. u.name as name,
  409. u.userIdentity,
  410. u.guideFlag as guideFlag,
  411. (select status from club where userId = u.userId limit 1) as clubStatus,
  412. u.manufacturerStatus as shopStatus,
  413. cou.invitationCodeTime,
  414. cou.mobile as operationMobile,
  415. cou.status as operationStatus,
  416. cou.delFlag
  417. FROM cm_mall_operation_user cou
  418. LEFT JOIN user u ON u.userID = cou.userID
  419. WHERE cou.id = #{operationId}
  420. AND cou.userOrganizeID = 0
  421. AND u.userIdentity in (2, 3, 4)
  422. </select>
  423. <select id="getOrganizeByOperationId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  424. SELECT cou.id as operationId,
  425. u.userID as userId,
  426. u.clubID as clubId,
  427. u.shopID as shopId,
  428. u.userName as userName,
  429. u.name as name,
  430. u.userIdentity,
  431. u.guideFlag as guideFlag,
  432. u.clubStatus as clubStatus,
  433. u.manufacturerStatus as shopStatus,
  434. cou.invitationCodeTime,
  435. cou.mobile as operationMobile,
  436. cou.status as operationStatus,
  437. cou.delFlag
  438. FROM cm_mall_operation_user cou
  439. LEFT JOIN user u ON u.userID = cou.userID
  440. WHERE cou.id = #{operationId}
  441. AND cou.userOrganizeID = #{organizeId}
  442. AND u.userIdentity in (2, 3, 4)
  443. </select>
  444. <select id="getClubCountByClubName" resultType="java.lang.Integer">
  445. SELECT count(*)
  446. FROM club
  447. WHERE name = #{name}
  448. AND status NOT IN (2, 20, 21, 3, 30)
  449. </select>
  450. <select id="getMaxClubId" resultType="java.lang.Integer">
  451. SELECT MAX(clubID)
  452. FROM club
  453. </select>
  454. <select id="getMaxUserId" resultType="java.lang.Integer">
  455. SELECT MAX(userID)
  456. FROM user
  457. </select>
  458. <select id="getClubTypeById" resultType="java.lang.Integer">
  459. SELECT firstClubType
  460. FROM club
  461. WHERE userID = #{userId}
  462. limit 1
  463. </select>
  464. <select id="getClubSpUserId" resultType="java.lang.Integer">
  465. SELECT s.userID from serviceprovider s
  466. left join club c on c.spId=s.serviceProviderID
  467. WHERE c.clubId = #{clubId}
  468. limit 1
  469. </select>
  470. </mapper>