LoginMapper.xml 21 KB

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