LoginMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. u.partnerId as partnerId,
  40. cu.id as operationId,
  41. cu.status as operationStatus,
  42. cu.mobile as operationMobile
  43. from user u
  44. left join cm_mall_operation_user cu on cu.userID = u.userID
  45. where (u.bindMobile = #{mobileOrEmail} or u.email = #{mobileOrEmail})
  46. and IF(u.userIdentity = 3, u.manufacturerStatus = 90, 1 = 1)
  47. and u.userIdentity in (1, 2, 3, 4)
  48. and u.userOrganizeID = 0
  49. union
  50. SELECT u.userID AS userId,
  51. u.userOrganizeID as organizeId,
  52. u.clubID AS clubId,
  53. u.shopID AS shopId,
  54. u.serviceProviderId AS serviceProviderId,
  55. u.userName AS userName,
  56. u.name AS NAME,
  57. u.mobile AS mobile,
  58. u.bindMobile AS bindMobile,
  59. u.email AS email,
  60. u.userIdentity AS userIdentity,
  61. u.password AS PASSWORD,
  62. u.guideFlag AS guideFlag,
  63. u.partnerId as partnerId,
  64. (select status from club where userId = u.userId limit 1) AS clubStatus,
  65. u.manufacturerStatus AS shopStatus,
  66. cu.id AS operationId,
  67. cu.status AS operationStatus,
  68. cu.mobile AS operationMobile
  69. FROM USER u
  70. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  71. WHERE cu.mobile = #{mobileOrEmail}
  72. and IF(u.userIdentity = 3, u.manufacturerStatus = 90, 1 = 1)
  73. and cu.delFlag != 1
  74. AND u.userIdentity IN (1, 2, 3, 4)
  75. AND u.userOrganizeID = 0
  76. limit 1
  77. </select>
  78. <select id="getLoginOrganizeUserByMobileOrEmail" resultType="com.caimei365.user.model.vo.UserLoginVo">
  79. select u.userID as userId,
  80. u.userOrganizeID as organizeId,
  81. u.clubID as clubId,
  82. u.shopID as shopId,
  83. u.serviceProviderId as serviceProviderId,
  84. u.userName as userName,
  85. u.name as name,
  86. (SELECT linkMan FROM club WHERE userId = u.userID) as clubLinkMan,
  87. u.mobile as mobile,
  88. u.bindMobile as bindMobile,
  89. u.email as email,
  90. u.userIdentity as userIdentity,
  91. u.password as password,
  92. u.guideFlag as guideFlag,
  93. (select status from club where userId = u.userId limit 1) as clubStatus,
  94. u.manufacturerStatus as shopStatus,
  95. u.serviceProviderStatus as serviceStatus,
  96. cu.id as operationId,
  97. cu.status as operationStatus,
  98. cu.mobile as operationMobile
  99. from user u
  100. left join cm_mall_operation_user cu on cu.userID = u.userID
  101. where (u.bindMobile = #{mobileOrEmail} or u.email = #{mobileOrEmail})
  102. and u.userIdentity in (1, 2, 3, 4)
  103. and u.userOrganizeID = 4
  104. union
  105. SELECT u.userID AS userId,
  106. u.userOrganizeID as organizeId,
  107. u.clubID AS clubId,
  108. u.shopID AS shopId,
  109. u.serviceProviderId AS serviceProviderId,
  110. u.userName AS userName,
  111. u.name AS NAME,
  112. (SELECT linkMan FROM club WHERE userId = u.userID) as clubLinkMan,
  113. u.mobile AS mobile,
  114. u.bindMobile AS bindMobile,
  115. u.email AS email,
  116. u.userIdentity AS userIdentity,
  117. u.password AS PASSWORD,
  118. u.guideFlag AS guideFlag,
  119. (select status from club where userId = u.userId limit 1) AS clubStatus,
  120. u.manufacturerStatus AS shopStatus,
  121. u.serviceProviderStatus as serviceStatus,
  122. cu.id AS operationId,
  123. cu.status AS operationStatus,
  124. cu.mobile AS operationMobile
  125. FROM USER u
  126. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  127. WHERE 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
  135. from cm_mall_operation_user
  136. where mobile = #{mobileOrEmail}
  137. and delFlag = 0
  138. and userOrganizeID = 4
  139. limit 1
  140. </select>
  141. <insert id="insertOperation">
  142. INSERT INTO cm_mall_operation_user (userOrganizeID, userType, userID, clubID, mobile, linkName, STATUS, unionId,
  143. bindTime, addTime, delFlag)
  144. values (#{organizeId}, #{userType}, #{userId}, #{clubId}, #{mobile}, #{linkName}, #{status}, #{unionId},
  145. #{bindTime}, #{addTime}, #{delFlag})
  146. </insert>
  147. <select id="getLoginUserByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
  148. select u.userID as userId,
  149. u.clubID as clubId,
  150. u.shopID as shopId,
  151. u.serviceProviderId as serviceProviderId,
  152. u.userName as userName,
  153. u.name as name,
  154. u.mobile as mobile,
  155. u.bindMobile as bindMobile,
  156. u.email as email,
  157. u.userIdentity as userIdentity,
  158. u.password as password,
  159. u.guideFlag as guideFlag,
  160. u.manufacturerStatus as shopStatus,
  161. cu.id as operationId,
  162. (select status from club where userId = u.userId limit 1) as clubStatus,
  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.userIdentity as userIdentity,
  180. u.guideFlag as guideFlag,
  181. u.password as password,
  182. s.insiderFlag as insideFlag
  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.userIdentity as userIdentity,
  214. u.password as password,
  215. u.guideFlag as guideFlag,
  216. (select status from club where userId = u.userId limit 1) as clubStatus,
  217. u.manufacturerStatus as shopStatus,
  218. o.unionId as unionId,
  219. o.status as operationStatus,
  220. o.mobile as operationMobile,
  221. <if test="source=='www'">
  222. o.pcOpenid as openId
  223. </if>
  224. <if test="source=='mini'">
  225. o.openid as openId
  226. </if>
  227. from user u
  228. left join cm_mall_operation_user o on o.userID = u.userID
  229. where (o.unionId = #{unionId} and o.delFlag = '0')
  230. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID = 0)
  231. limit 1
  232. </select>
  233. <select id="getOrganizeLoginUserByUnionId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  234. select u.userID as userId,
  235. u.clubID as clubId,
  236. u.shopID as shopId,
  237. u.serviceProviderId as serviceProviderId,
  238. u.userName as userName,u.name as name,
  239. u.mobile as mobile,
  240. u.bindMobile as bindMobile,
  241. u.email as email,
  242. u.userIdentity as userIdentity,
  243. u.serviceProviderID as serviceProviderId,
  244. u.password as password,
  245. u.guideFlag as guideFlag,
  246. c.status as clubStatus,
  247. u.manufacturerStatus as shopStatus,
  248. u.serviceProviderStatus as serviceStatus,
  249. o.unionId as unionId,
  250. o.status as operationStatus,
  251. o.mobile as operationMobile,
  252. c.headpic AS shopPhoto,
  253. <if test="source=='www'">
  254. o.pcOpenid as openId
  255. </if>
  256. <if test="source=='mini'">
  257. o.openid as openId
  258. </if>
  259. from user u
  260. left join cm_mall_operation_user o on o.userID = u.userID
  261. LEFT JOIN club c ON c.userID = u.userID
  262. where (o.unionId = #{unionId} and o.delFlag = '0')
  263. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID != 0)
  264. limit 1
  265. </select>
  266. <select id="getLoginUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  267. select u.userID as userId,
  268. u.clubID as clubId,
  269. u.shopID as shopId,
  270. u.serviceProviderId as serviceProviderId,
  271. u.userName as userName,u.name as name,
  272. u.mobile as mobile,
  273. u.bindMobile as bindMobile,
  274. u.email as email,
  275. u.userIdentity as userIdentity,
  276. u.password as password,
  277. u.guideFlag as guideFlag,
  278. (select status from club where userId = u.userId limit 1) as clubStatus,
  279. u.manufacturerStatus as shopStatus,
  280. o.unionId as unionId,
  281. o.status as operationStatus,
  282. o.mobile as operationMobile,
  283. <if test="source=='www'">
  284. o.pcOpenid as openId
  285. </if>
  286. <if test="source=='mini'">
  287. o.openid as openId
  288. </if>
  289. from user u
  290. left join cm_mall_operation_user o on o.userID = u.userID
  291. where (
  292. <if test="source=='www'">
  293. o.pcOpenid = #{openId}
  294. </if>
  295. <if test="source=='crm'">
  296. o.crmOpenid = #{openId}
  297. </if>
  298. <if test="source=='mini'">
  299. o.openid = #{openId}
  300. </if>
  301. and o.delFlag = '0')
  302. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID = 0)
  303. limit 1
  304. </select>
  305. <select id="getOrganizeLoginUserByOpenId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  306. select u.userID as userId,
  307. u.clubID as clubId,
  308. u.shopID as shopId,
  309. u.serviceProviderId as serviceProviderId,
  310. u.userName as userName,u.name as name,
  311. u.mobile as mobile,
  312. u.bindMobile as bindMobile,
  313. u.email as email,
  314. u.userIdentity as userIdentity,
  315. u.serviceProviderID as serviceProviderId,
  316. u.password as password,
  317. u.guideFlag as guideFlag,
  318. c.status as clubStatus,
  319. u.manufacturerStatus as shopStatus,
  320. o.unionId as unionId,
  321. o.status as operationStatus,
  322. o.mobile as operationMobile,
  323. c.headpic AS shopPhoto,
  324. <if test="source=='www'">
  325. o.pcOpenid as openId
  326. </if>
  327. <if test="source=='mini'">
  328. o.openid as openId
  329. </if>
  330. from user u
  331. left join cm_mall_operation_user o on o.userID = u.userID
  332. LEFT JOIN club c ON c.userID = u.userID
  333. where (
  334. <if test="source=='www'">
  335. o.pcOpenid = #{openId}
  336. </if>
  337. <if test="source=='crm'">
  338. o.crmOpenid = #{openId}
  339. </if>
  340. <if test="source=='mini'">
  341. o.openid = #{openId}
  342. </if>
  343. and o.delFlag = '0')
  344. and (u.userIdentity in (1,2,3,4) and u.userOrganizeID != 0)
  345. limit 1
  346. </select>
  347. <update id="updateServiceProviderUnionId">
  348. update serviceprovider
  349. set unionId = #{unionId}
  350. where userID = #{userId}
  351. </update>
  352. <update id="updateLogin">
  353. update user
  354. set loginTime = now()
  355. where userID = #{userId}
  356. </update>
  357. <select id="getShopProductGroudMall" resultType="java.lang.String">
  358. select p.groundMall AS groundMall
  359. from product p
  360. left join cm_organize_product_info copi on copi.productId = p.productID
  361. where p.shopId = #{shopId}
  362. and copi.validFlag = 2
  363. </select>
  364. <select id="getUserIdByOpenId" resultType="java.lang.Integer">
  365. select o.userID as userId
  366. from
  367. cm_mall_operation_user o
  368. where
  369. <if test="source=='www'">
  370. pcOpenid = #{openId}
  371. </if>
  372. <if test="source=='mini'">
  373. openid = #{openId}
  374. </if>
  375. and delFlag = '0'
  376. and userOrganizeID=0
  377. limit 1
  378. </select>
  379. <select id="getOperationUserByInvitationCode" resultType="com.caimei365.user.model.vo.UserLoginVo">
  380. SELECT cou.id as operationId,
  381. u.userID as userId,
  382. u.clubID as clubId,
  383. u.shopID as shopId,
  384. u.userName as userName,
  385. u.name as name,
  386. ifnull(cou.userOrganizeID, 0) as organizeId,
  387. u.userIdentity,
  388. u.guideFlag as guideFlag,
  389. (select status from club where userId = u.userId limit 1) as clubStatus,
  390. u.manufacturerStatus as shopStatus,
  391. cou.invitationCodeTime,
  392. cou.mobile as operationMobile,
  393. cou.status as operationStatus,
  394. cou.delFlag
  395. FROM cm_mall_operation_user cou
  396. LEFT JOIN user u ON u.userID = cou.userID
  397. WHERE cou.invitationCode = #{invitationCode}
  398. AND cou.userOrganizeID = #{organizeId}
  399. AND u.userIdentity in (2, 3, 4)
  400. </select>
  401. <select id="getOperationOrganizeUserByInvitationCode" resultType="com.caimei365.user.model.vo.UserLoginVo">
  402. SELECT cou.id as operationId,
  403. u.userID as userId,
  404. u.clubID as clubId,
  405. u.shopID as shopId,
  406. u.userName as userName,
  407. u.name as name,
  408. ifnull(cou.userOrganizeID, 0) as organizeId,
  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.invitationCode = #{invitationCode}
  420. AND cou.userOrganizeID = #{organizeId}
  421. AND u.userIdentity in (2, 3, 4)
  422. </select>
  423. <select id="getOperationUserByOperationId" 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. (select status from club where userId = u.userId limit 1) 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 = 0
  442. AND u.userIdentity in (2, 3, 4)
  443. </select>
  444. <select id="getOrganizeByOperationId" resultType="com.caimei365.user.model.vo.UserLoginVo">
  445. SELECT cou.id as operationId,
  446. u.userID as userId,
  447. u.clubID as clubId,
  448. u.shopID as shopId,
  449. u.userName as userName,
  450. u.name as name,
  451. u.userIdentity,
  452. u.guideFlag as guideFlag,
  453. u.clubStatus as clubStatus,
  454. u.manufacturerStatus as shopStatus,
  455. cou.invitationCodeTime,
  456. cou.mobile as operationMobile,
  457. cou.status as operationStatus,
  458. cou.delFlag
  459. FROM cm_mall_operation_user cou
  460. LEFT JOIN user u ON u.userID = cou.userID
  461. WHERE cou.id = #{operationId}
  462. AND cou.userOrganizeID = #{organizeId}
  463. AND u.userIdentity in (2, 3, 4)
  464. </select>
  465. <select id="getClubCountByClubName" resultType="java.lang.Integer">
  466. SELECT count(*)
  467. FROM club
  468. WHERE name = #{name}
  469. AND status NOT IN (2, 20, 21, 3, 30)
  470. </select>
  471. <select id="getMaxClubId" resultType="java.lang.Integer">
  472. SELECT MAX(clubID)
  473. FROM club
  474. </select>
  475. <select id="getMaxUserId" resultType="java.lang.Integer">
  476. SELECT MAX(userID)
  477. FROM user
  478. </select>
  479. <select id="getClubTypeById" resultType="java.lang.Integer">
  480. SELECT firstClubType
  481. FROM club
  482. WHERE userID = #{userId}
  483. limit 1
  484. </select>
  485. <select id="getClubSpUserId" resultType="java.lang.Integer">
  486. SELECT s.userID
  487. from serviceprovider s
  488. left join club c on c.spId = s.serviceProviderID
  489. WHERE c.clubId = #{clubId}
  490. limit 1
  491. </select>
  492. <update id="updateTourist">
  493. update cm_behavior_tourist_info
  494. set userId = #{userId}
  495. where touristId = #{touristId}
  496. </update>
  497. <select id="findTemPass" resultType="java.lang.String">
  498. select password
  499. from cm_temporary_user
  500. where addtime >= NOW() - INTERVAL 10 MINUTE
  501. and userId = #{userId}
  502. </select>
  503. <select id="findTicket" resultType="com.caimei365.user.model.po.TicketPo">
  504. select userId, ticketId, idCard, name, mobile, work
  505. from cm_zyl_ticket
  506. where ticketId = #{ticket}
  507. </select>
  508. <update id="updateTicket">
  509. update cm_zyl_ticket
  510. set userId = #{userId},
  511. idCard = #{idCard},
  512. name = #{name},
  513. mobile = #{mobile},
  514. work = #{work},
  515. bindTime = now()
  516. where ticketId = #{ticket}
  517. </update>
  518. <select id="findTicketUser" resultType="com.caimei365.user.model.po.TicketPo">
  519. select userId, ticketId, idCard
  520. from cm_zyl_ticket
  521. where userId = #{userId}
  522. </select>
  523. <select id="findShopSign" resultType="java.lang.String">
  524. select shopIds
  525. from cm_zyl_ticket
  526. where userId = #{userId}
  527. </select>
  528. <update id="updateShopSign">
  529. update cm_zyl_ticket
  530. set shopIds = #{shopSign}
  531. where userId = #{userId}
  532. </update>
  533. <select id="findShopSignPos" resultType="com.caimei365.user.model.po.ShopSignPo">
  534. SELECT id, shopName, shopLogo, (SELECT shopIds FROM cm_zyl_ticket where userId = #{userId}) as shopIds
  535. FROM cm_zyl_shop
  536. </select>
  537. <select id="findShopDetail" resultType="com.caimei365.user.model.po.ShopSignPo">
  538. SELECT id, shopName, shopLogo, showNum, (SELECT shopIds FROM cm_zyl_ticket where userId = #{userId}) as shopIds
  539. FROM cm_zyl_shop
  540. where id = #{shopId}
  541. </select>
  542. </mapper>