BaseMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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.BaseMapper">
  4. <update id="updatePasswordByUserId">
  5. update user
  6. set password = #{password}
  7. where userID = #{userId}
  8. </update>
  9. <update id="updateMobileByUserId">
  10. update user
  11. set bindMobile = #{mobile}
  12. where userID = #{userId}
  13. </update>
  14. <update id="updateImageByUserId">
  15. update user
  16. <trim prefix="SET" suffixOverrides=",">
  17. <if test="image != null and image != ''">image = #{image},</if>
  18. </trim>
  19. where userId = #{userId}
  20. </update>
  21. <update id="updateShopMobileByShopId">
  22. update shop
  23. set contractMobile = #{mobile}
  24. where shopID = #{shopId}
  25. </update>
  26. <update id="updateClubMobileByClubId">
  27. update club
  28. set contractMobile = #{mobile}
  29. where clubID = #{clubId}
  30. </update>
  31. <select id="getUserIdByEmail" resultType="java.lang.Integer">
  32. select userID
  33. from user
  34. where email = #{email}
  35. and userIdentity in (1, 2, 3, 4)
  36. limit 1
  37. </select>
  38. <select id="getUserIdByUserId" resultType="java.lang.Integer">
  39. select userID
  40. from user
  41. where userID = #{userId}
  42. and userIdentity in (1, 2, 3, 4)
  43. limit 1
  44. </select>
  45. <select id="getUserIdByMobile" resultType="java.lang.Integer">
  46. SELECT u.userID
  47. FROM USER u
  48. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  49. WHERE u.bindMobile = #{mobile}
  50. and u.userIdentity in (1, 2, 3, 4,7)
  51. UNION
  52. SELECT u.userID
  53. FROM USER u
  54. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  55. WHERE cu.mobile = #{mobile}
  56. AND cu.delFlag != 1
  57. AND u.userIdentity IN (1, 2, 3, 4)
  58. LIMIT 1
  59. </select>
  60. <select id="getUserIdOrganizeByMobile" resultType="java.lang.Integer">
  61. SELECT u.userID
  62. FROM USER u
  63. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  64. WHERE u.bindMobile = #{mobile} and u.userOrganizeID != 0
  65. and u.userIdentity in (1, 2, 3, 4)
  66. UNION
  67. SELECT u.userID
  68. FROM USER u
  69. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  70. WHERE cu.mobile = #{mobile}
  71. AND cu.delFlag != 1
  72. AND u.userIdentity IN (1, 2, 3, 4) and u.userOrganizeID != 0
  73. LIMIT 1
  74. </select>
  75. <select id="getUserIdByOrganize" resultType="java.lang.Integer">
  76. SELECT u.userID
  77. FROM USER u
  78. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  79. WHERE u.userOrganizeID = #{organizeId}
  80. and u.bindMobile = #{mobile}
  81. and u.userIdentity in (1, 2, 3, 4)
  82. UNION
  83. SELECT u.userID
  84. FROM USER u
  85. LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
  86. WHERE u.userOrganizeID = #{organizeId}
  87. AND cu.mobile = #{mobile}
  88. AND cu.delFlag != 1
  89. AND u.userIdentity IN (1, 2, 3, 4)
  90. LIMIT 1
  91. </select>
  92. <select id="getServiceProvider" resultType="com.caimei365.user.model.vo.UserLoginVo">
  93. SELECT serviceProviderID as serviceProviderId, status as operationStatus FROM serviceprovider WHERE contractMobile = #{mobile} and organizeId = 4 limit 1
  94. </select>
  95. <select id="getUserIdByOrganizeStatus" resultType="com.caimei365.user.model.vo.UserLoginVo">
  96. SELECT userId, userIdentity, clubStatus
  97. FROM USER
  98. WHERE userOrganizeID = #{organizeId}
  99. AND bindMobile = #{mobile}
  100. AND userIdentity IN (1, 2, 3, 4)
  101. LIMIT 1
  102. </select>
  103. <select id="getOperationUserIdByMobile" resultType="java.lang.Integer">
  104. select userID
  105. from cm_mall_operation_user
  106. where mobile = #{mobile}
  107. and delFlag = '0'
  108. limit 1
  109. </select>
  110. <select id="getClubStatusByUserId" resultType="java.lang.Integer">
  111. select clubStatus
  112. from user
  113. where userID = #{userId}
  114. </select>
  115. <select id="getShopStatusByUserId" resultType="java.lang.Integer">
  116. select manufacturerStatus
  117. from user
  118. where userID = #{userId}
  119. </select>
  120. <select id="getOperationIdByMobile" resultType="java.lang.Integer">
  121. select id
  122. from cm_mall_operation_user
  123. where mobile = #{mobile}
  124. and delFlag = '0'
  125. limit 1
  126. </select>
  127. <select id="getOrganizeOperationIdByMobile" resultType="java.lang.Integer">
  128. select id
  129. from cm_mall_operation_user
  130. where mobile = #{mobile} and userOrganizeID = #{organizeId}
  131. and delFlag = '0'
  132. limit 1
  133. </select>
  134. <select id="getProvince" resultType="com.caimei365.user.model.vo.ProvinceVo">
  135. select provinceID as provinceId, name, validFlag, deliveryFee, freeMinTotalPrice
  136. from province
  137. where provinceID = #{provinceId}
  138. </select>
  139. <select id="getCity" resultType="com.caimei365.user.model.vo.CityVo">
  140. select cityID as cityId, provinceID as provinceId, name, validFlag
  141. from city
  142. where cityID = #{cityId}
  143. </select>
  144. <select id="getTown" resultType="com.caimei365.user.model.vo.TownVo">
  145. select townID as townId, cityID as cityId, name, zip, telZip, validFlag
  146. from town
  147. where townID = #{townID}
  148. </select>
  149. <select id="getUserByUserId" resultType="com.caimei365.user.model.vo.UserVo">
  150. select userID as userId,
  151. registerUserTypeID as registerUserTypeId,
  152. source,
  153. clubID as clubId,
  154. shopID as shopId,
  155. serviceProviderID as serviceProviderId,
  156. name,
  157. userName,
  158. email,
  159. mobile,
  160. bindMobile,
  161. password,
  162. userIdentity,
  163. userPermission,
  164. clubStatus,
  165. manufacturerStatus,
  166. serviceProviderStatus,
  167. auditNote,
  168. auditStatus,
  169. agreeFlag,
  170. registerTime,
  171. registerIP as registerIp,
  172. guideFlag,
  173. validFlag,
  174. userBeans,
  175. ableUserMoney,
  176. image
  177. from user
  178. where userID = #{userId}
  179. </select>
  180. <select id="getUserNameByUserId" resultType="java.lang.String">
  181. select userName
  182. from user
  183. where userID = #{userId}
  184. </select>
  185. <select id="getAfterSalesPhone" resultType="java.lang.String">
  186. select contactNumber
  187. from cm_mall_organize
  188. where id = 0
  189. and delFlag = '0'
  190. </select>
  191. <select id="getSensitiveWords" resultType="java.lang.String">
  192. select words
  193. from cm_sensitive_words
  194. where id = 1 and status = 1
  195. <if test="checkPoint != null">
  196. and checkPoints like concat('%',#{checkPoint},'%')
  197. </if>
  198. </select>
  199. <select id="findLabelsByLableIds" resultType="java.lang.String">
  200. select keyword
  201. from cm_user_search_frequency
  202. where trueStatus = 1
  203. and delStatus = 1
  204. and id in (#{labelIds})
  205. </select>
  206. <select id="findBankByUserId" resultType="java.lang.Integer">
  207. SELECT COUNT(id)
  208. FROM cm_quickpay_info
  209. WHERE userId = #{userId}
  210. and delflag = 0
  211. </select>
  212. <select id="getByUserId" resultType="java.lang.Integer">
  213. <if test="userType != null">
  214. <if test="userType == 1">
  215. SELECT userID from club WHERE clubId = #{id}
  216. </if>
  217. <if test="userType == 2">
  218. SELECT userID from shop WHERE shopId = #{id}
  219. </if>
  220. <if test="userType == 3">
  221. SELECT userID from serviceprovider WHERE serviceProviderID = #{id}
  222. </if>
  223. </if>
  224. </select>
  225. <select id="getByMobile" resultType="String">
  226. select bindMobile from user where userIdentity=#{userIdentity} and userId=#{userId}
  227. </select>
  228. <select id="getByUserCount" resultType="java.lang.Integer">
  229. SELECT count(1) from user
  230. <where>
  231. <if test="userID != null and userID != ''">
  232. and user.userID
  233. <if test="userID.toUpperCase().indexOf('=')==-1">
  234. = #{userID}
  235. </if>
  236. <if test="userID.toUpperCase().indexOf('=')!=-1">
  237. <if test="userID.toUpperCase().indexOf('NOT')!=-1"> not </if>
  238. <if test="userID.toUpperCase().indexOf('IN')!=-1"> in </if>
  239. <foreach item="userIDIn" collection="userID.substring(userID.toUpperCase().indexOf('=')+1,userID.length()).trim().split(',')" open="(" separator="," close=")">
  240. #{userIDIn}
  241. </foreach>
  242. </if>
  243. </if>
  244. <if test="userOrganizeID != null and userOrganizeID != ''">
  245. and user.userOrganizeID
  246. <if test="userOrganizeID.toUpperCase().indexOf('=')==-1">
  247. = #{userOrganizeID}
  248. </if>
  249. <if test="userOrganizeID.toUpperCase().indexOf('=')!=-1">
  250. <if test="userOrganizeID.toUpperCase().indexOf('NOT')!=-1"> not </if>
  251. <if test="userOrganizeID.toUpperCase().indexOf('IN')!=-1"> in </if>
  252. <foreach item="typeIn" collection="userOrganizeID.substring(userOrganizeID.toUpperCase().indexOf('=')+1,userOrganizeID.length()).trim().split(',')" open="(" separator="," close=")">
  253. #{typeIn}
  254. </foreach>
  255. </if>
  256. </if>
  257. <if test="account != null and account != ''"> and user.account = #{account}</if>
  258. <if test="mobile != null and mobile != ''"> and user.mobile = #{mobile}</if>
  259. <if test="bindMobile != null and bindMobile != ''"> and user.bindMobile = #{bindMobile}</if>
  260. <if test="userPermission != null "> and user.userPermission = #{userPermission}</if>
  261. <if test="userIdentity != null and userIdentity != ''">
  262. and user.userIdentity
  263. <if test="userIdentity.toUpperCase().indexOf('=')==-1">
  264. = #{userIdentity}
  265. </if>
  266. <if test="userIdentity.toUpperCase().indexOf('=')!=-1">
  267. <if test="userIdentity.toUpperCase().indexOf('NOT')!=-1"> not </if>
  268. <if test="userIdentity.toUpperCase().indexOf('IN')!=-1"> in </if>
  269. <foreach item="typeIn" collection="userIdentity.substring(userIdentity.toUpperCase().indexOf('=')+1,userIdentity.length()).trim().split(',')" open="(" separator="," close=")">
  270. #{typeIn}
  271. </foreach>
  272. </if>
  273. </if>
  274. <if test="email != null and email != ''"> and user.email = #{email}</if>
  275. <if test="userName != null and userName != ''"> and user.userName like concat('%', #{userName}, '%')</if>
  276. <if test="realName != null and realName != ''"> and user.realName like concat('%', #{realName}, '%')</if>
  277. <if test="source != null and source != ''"> and user.source = #{source}</if>
  278. <if test="image != null and image != ''"> and user.image = #{image}</if>
  279. <if test="password != null and password != ''"> and user.password = #{password}</if>
  280. <if test="name != null and name != ''"> and user.name like concat('%', #{name}, '%')</if>
  281. <if test="registerUserTypeID != null and registerUserTypeID != ''">
  282. and user.registerUserTypeID
  283. <if test="registerUserTypeID.toUpperCase().indexOf('=')==-1">
  284. = #{registerUserTypeID}
  285. </if>
  286. <if test="registerUserTypeID.toUpperCase().indexOf('=')!=-1">
  287. <if test="registerUserTypeID.toUpperCase().indexOf('NOT')!=-1"> not </if>
  288. <if test="registerUserTypeID.toUpperCase().indexOf('IN')!=-1"> in </if>
  289. <foreach item="typeIn" collection="registerUserTypeID.substring(registerUserTypeID.toUpperCase().indexOf('=')+1,registerUserTypeID.length()).trim().split(',')" open="(" separator="," close=")">
  290. #{typeIn}
  291. </foreach>
  292. </if>
  293. </if>
  294. <if test="manufacturerStatus != null "> and user.manufacturerStatus = #{manufacturerStatus}</if>
  295. <if test="shopID != null "> and user.shopID = #{shopID}</if>
  296. <if test="auditStatus != null and auditStatus != ''"> and user.auditStatus = #{auditStatus}</if>
  297. <if test="auditTime != null and auditTime != ''"> and user.auditTime = #{auditTime}</if>
  298. <if test="auditNote != null and auditNote != ''"> and user.auditNote = #{auditNote}</if>
  299. <if test="registerTime != null and registerTime != ''"> and user.registerTime = #{registerTime}</if>
  300. <if test="registerIP != null and registerIP != ''"> and user.registerIP = #{registerIP}</if>
  301. <if test="ipAddress != null and ipAddress != ''"> and user.ipAddress = #{ipAddress}</if>
  302. <if test="loginTime != null and loginTime != ''"> and user.loginTime = #{loginTime}</if>
  303. <if test="loginIP != null and loginIP != ''"> and user.loginIP = #{loginIP}</if>
  304. <if test="validFlag != null and validFlag != ''"> and user.validFlag = #{validFlag}</if>
  305. <if test="clubStatus != null "> and user.clubStatus = #{clubStatus}</if>
  306. <if test="clubID != null "> and user.clubID = #{clubID}</if>
  307. <if test="agreeFlag != null and agreeFlag != ''"> and user.agreeFlag = #{agreeFlag}</if>
  308. <if test="serviceProviderStatus != null "> and user.serviceProviderStatus = #{serviceProviderStatus}</if>
  309. <if test="serviceProviderID != null "> and user.serviceProviderID = #{serviceProviderID}</if>
  310. <if test="userMoney != null "> and user.userMoney = #{userMoney}</if>
  311. <if test="ableUserMoney != null "> and user.ableUserMoney = #{ableUserMoney}</if>
  312. <if test="logoffTime != null and logoffTime != ''"> and user.logoffTime = #{logoffTime}</if>
  313. <if test="appKey != null and appKey != ''"> and user.appKey = #{appKey}</if>
  314. <if test="appSecret != null and appSecret != ''"> and user.appSecret = #{appSecret}</if>
  315. <if test="scanFlag != null "> and user.scanFlag = #{scanFlag}</if>
  316. <if test="userBeans != null "> and user.userBeans = #{userBeans}</if>
  317. <if test="guideFlag != null "> and user.guideFlag = #{guideFlag}</if>
  318. <if test="loginFailTime != null "> and user.loginFailTime = #{loginFailTime}</if>
  319. <if test="tipStatus != null and tipStatus != ''"> and user.tipStatus = #{tipStatus}</if>
  320. <if test="onlineMoney != null "> and user.onlineMoney = #{onlineMoney}</if>
  321. </where>
  322. group by user.userID
  323. order by user.loginTime desc
  324. </select>
  325. <insert id="addUser" parameterType="CmUser" useGeneratedKeys="true" keyProperty="userID">
  326. insert into user
  327. <trim prefix="(" suffix=")" suffixOverrides=",">
  328. <if test="userID != null and userID != ''">userID,</if>
  329. <if test="userOrganizeID != null">userOrganizeID,</if>
  330. <if test="account != null and account != ''">account,</if>
  331. <if test="mobile != null and mobile != ''">mobile,</if>
  332. <if test="bindMobile != null and bindMobile != ''">bindMobile,</if>
  333. <if test="userPermission != null">userPermission,</if>
  334. <if test="userIdentity != null">userIdentity,</if>
  335. <if test="email != null and email != ''">email,</if>
  336. <if test="userName != null and userName != ''">userName,</if>
  337. <if test="realName != null and realName != ''">realName,</if>
  338. <if test="source != null and source != ''">source,</if>
  339. <if test="image != null and image != ''">image,</if>
  340. <if test="password != null and password != ''">password,</if>
  341. <if test="name != null and name != ''">name,</if>
  342. <if test="registerUserTypeID != null and registerUserTypeID != ''">registerUserTypeID,</if>
  343. <if test="manufacturerStatus != null">manufacturerStatus,</if>
  344. <if test="shopID != null">shopID,</if>
  345. <if test="auditStatus != null and auditStatus != ''">auditStatus,</if>
  346. <if test="auditTime != null and auditTime != ''">auditTime,</if>
  347. <if test="auditNote != null and auditNote != ''">auditNote,</if>
  348. <if test="registerTime != null and registerTime != ''">registerTime,</if>
  349. <if test="registerIP != null and registerIP != ''">registerIP,</if>
  350. <if test="ipAddress != null and ipAddress != ''">ipAddress,</if>
  351. <if test="loginTime != null and loginTime != ''">loginTime,</if>
  352. <if test="loginIP != null and loginIP != ''">loginIP,</if>
  353. <if test="validFlag != null and validFlag != ''">validFlag,</if>
  354. <if test="clubStatus != null">clubStatus,</if>
  355. <if test="clubID != null">clubID,</if>
  356. <if test="agreeFlag != null and agreeFlag != ''">agreeFlag,</if>
  357. <if test="serviceProviderStatus != null">serviceProviderStatus,</if>
  358. <if test="serviceProviderID != null">serviceProviderID,</if>
  359. <if test="userMoney != null">userMoney,</if>
  360. <if test="ableUserMoney != null">ableUserMoney,</if>
  361. <if test="logoffTime != null and logoffTime != ''">logoffTime,</if>
  362. <if test="appKey != null and appKey != ''">appKey,</if>
  363. <if test="appSecret != null and appSecret != ''">appSecret,</if>
  364. <if test="scanFlag != null">scanFlag,</if>
  365. <if test="userBeans != null">userBeans,</if>
  366. <if test="guideFlag != null">guideFlag,</if>
  367. <if test="loginFailTime != null">loginFailTime,</if>
  368. <if test="tipStatus != null and tipStatus != ''">tipStatus,</if>
  369. <if test="onlineMoney != null">onlineMoney,</if>
  370. </trim>
  371. <trim prefix="values (" suffix=")" suffixOverrides=",">
  372. <if test="userID != null and userID != ''">#{userID},</if>
  373. <if test="userOrganizeID != null">#{userOrganizeID},</if>
  374. <if test="account != null and account != ''">#{account},</if>
  375. <if test="mobile != null and mobile != ''">#{mobile},</if>
  376. <if test="bindMobile != null and bindMobile != ''">#{bindMobile},</if>
  377. <if test="userPermission != null">#{userPermission},</if>
  378. <if test="userIdentity != null">#{userIdentity},</if>
  379. <if test="email != null and email != ''">#{email},</if>
  380. <if test="userName != null and userName != ''">#{userName},</if>
  381. <if test="realName != null and realName != ''">#{realName},</if>
  382. <if test="source != null and source != ''">#{source},</if>
  383. <if test="image != null and image != ''">#{image},</if>
  384. <if test="password != null and password != ''">#{password},</if>
  385. <if test="name != null and name != ''">#{name},</if>
  386. <if test="registerUserTypeID != null and registerUserTypeID != ''">#{registerUserTypeID},</if>
  387. <if test="manufacturerStatus != null">#{manufacturerStatus},</if>
  388. <if test="shopID != null">#{shopID},</if>
  389. <if test="auditStatus != null and auditStatus != ''">#{auditStatus},</if>
  390. <if test="auditTime != null and auditTime != ''">#{auditTime},</if>
  391. <if test="auditNote != null and auditNote != ''">#{auditNote},</if>
  392. <if test="registerTime != null and registerTime != ''">#{registerTime},</if>
  393. <if test="registerIP != null and registerIP != ''">#{registerIP},</if>
  394. <if test="ipAddress != null and ipAddress != ''">#{ipAddress},</if>
  395. <if test="loginTime != null and loginTime != ''">#{loginTime},</if>
  396. <if test="loginIP != null and loginIP != ''">#{loginIP},</if>
  397. <if test="validFlag != null and validFlag != ''">#{validFlag},</if>
  398. <if test="clubStatus != null">#{clubStatus},</if>
  399. <if test="clubID != null">#{clubID},</if>
  400. <if test="agreeFlag != null and agreeFlag != ''">#{agreeFlag},</if>
  401. <if test="serviceProviderStatus != null">#{serviceProviderStatus},</if>
  402. <if test="serviceProviderID != null">#{serviceProviderID},</if>
  403. <if test="userMoney != null">#{userMoney},</if>
  404. <if test="ableUserMoney != null">#{ableUserMoney},</if>
  405. <if test="logoffTime != null and logoffTime != ''">#{logoffTime},</if>
  406. <if test="appKey != null and appKey != ''">#{appKey},</if>
  407. <if test="appSecret != null and appSecret != ''">#{appSecret},</if>
  408. <if test="scanFlag != null">#{scanFlag},</if>
  409. <if test="userBeans != null">#{userBeans},</if>
  410. <if test="guideFlag != null">#{guideFlag},</if>
  411. <if test="loginFailTime != null">#{loginFailTime},</if>
  412. <if test="tipStatus != null and tipStatus != ''">#{tipStatus},</if>
  413. <if test="onlineMoney != null">#{onlineMoney},</if>
  414. </trim>
  415. </insert>
  416. <update id="updateUser" parameterType="CmUser">
  417. update user
  418. <trim prefix="SET" suffixOverrides=",">
  419. <if test="userOrganizeID != null">userOrganizeID = #{userOrganizeID},</if>
  420. <if test="account != null and account != ''">account = #{account},</if>
  421. <if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
  422. <if test="bindMobile != null and bindMobile != ''">bindMobile = #{bindMobile},</if>
  423. <if test="userPermission != null">userPermission = #{userPermission},</if>
  424. <if test="userIdentity != null">userIdentity = #{userIdentity},</if>
  425. <if test="email != null and email != ''">email = #{email},</if>
  426. <if test="userName != null and userName != ''">userName = #{userName},</if>
  427. <if test="realName != null and realName != ''">realName = #{realName},</if>
  428. <if test="source != null and source != ''">source = #{source},</if>
  429. <if test="image != null and image != ''">image = #{image},</if>
  430. <if test="password != null and password != ''">password = #{password},</if>
  431. <if test="name != null and name != ''">name = #{name},</if>
  432. <if test="registerUserTypeID != null and registerUserTypeID != ''">registerUserTypeID = #{registerUserTypeID},</if>
  433. <if test="manufacturerStatus != null">manufacturerStatus = #{manufacturerStatus},</if>
  434. <if test="shopID != null">shopID = #{shopID},</if>
  435. <if test="auditStatus != null and auditStatus != ''">auditStatus = #{auditStatus},</if>
  436. <if test="auditTime != null and auditTime != ''">auditTime = #{auditTime},</if>
  437. <if test="auditNote != null and auditNote != ''">auditNote = #{auditNote},</if>
  438. <if test="registerTime != null and registerTime != ''">registerTime = #{registerTime},</if>
  439. <if test="registerIP != null and registerIP != ''">registerIP = #{registerIP},</if>
  440. <if test="ipAddress != null and ipAddress != ''">ipAddress = #{ipAddress},</if>
  441. <if test="loginTime != null and loginTime != ''">loginTime = #{loginTime},</if>
  442. <if test="loginIP != null and loginIP != ''">loginIP = #{loginIP},</if>
  443. <if test="validFlag != null and validFlag != ''">validFlag = #{validFlag},</if>
  444. <if test="clubStatus != null">clubStatus = #{clubStatus},</if>
  445. <if test="clubID != null">clubID = #{clubID},</if>
  446. <if test="agreeFlag != null and agreeFlag != ''">agreeFlag = #{agreeFlag},</if>
  447. <if test="serviceProviderStatus != null">serviceProviderStatus = #{serviceProviderStatus},</if>
  448. <if test="serviceProviderID != null">serviceProviderID = #{serviceProviderID},</if>
  449. <if test="userMoney != null">userMoney = #{userMoney},</if>
  450. <if test="ableUserMoney != null">ableUserMoney = #{ableUserMoney},</if>
  451. <if test="logoffTime != null and logoffTime != ''">logoffTime = #{logoffTime},</if>
  452. <if test="appKey != null and appKey != ''">appKey = #{appKey},</if>
  453. <if test="appSecret != null and appSecret != ''">appSecret = #{appSecret},</if>
  454. <if test="scanFlag != null">scanFlag = #{scanFlag},</if>
  455. <if test="userBeans != null">userBeans = #{userBeans},</if>
  456. <if test="guideFlag != null">guideFlag = #{guideFlag},</if>
  457. <if test="loginFailTime != null">loginFailTime = #{loginFailTime},</if>
  458. <if test="tipStatus != null and tipStatus != ''">tipStatus = #{tipStatus},</if>
  459. <if test="onlineMoney != null">onlineMoney = #{onlineMoney},</if>
  460. </trim>
  461. where userID = #{userID}
  462. </update>
  463. <update id="updateClubStatus" parameterType="CmUser">
  464. update club
  465. <trim prefix="SET" suffixOverrides=",">
  466. <if test="status != null">status = #{status},</if>
  467. </trim>
  468. where userId = #{userId}
  469. </update>
  470. <resultMap type="CmUser" id="UserResult">
  471. <result property="userID" column="userID" />
  472. <result property="userOrganizeID" column="userOrganizeID" />
  473. <result property="account" column="account" />
  474. <result property="mobile" column="mobile" />
  475. <result property="bindMobile" column="bindMobile" />
  476. <result property="userPermission" column="userPermission" />
  477. <result property="userIdentity" column="userIdentity" />
  478. <result property="email" column="email" />
  479. <result property="userName" column="userName" />
  480. <result property="realName" column="realName" />
  481. <result property="source" column="source" />
  482. <result property="image" column="image" />
  483. <result property="password" column="password" />
  484. <result property="name" column="name" />
  485. <result property="registerUserTypeID" column="registerUserTypeID" />
  486. <result property="manufacturerStatus" column="manufacturerStatus" />
  487. <result property="shopID" column="shopID" />
  488. <result property="auditStatus" column="auditStatus" />
  489. <result property="auditTime" column="auditTime" />
  490. <result property="auditNote" column="auditNote" />
  491. <result property="registerTime" column="registerTime" />
  492. <result property="registerIP" column="registerIP" />
  493. <result property="ipAddress" column="ipAddress" />
  494. <result property="loginTime" column="loginTime" />
  495. <result property="loginIP" column="loginIP" />
  496. <result property="validFlag" column="validFlag" />
  497. <result property="clubStatus" column="clubStatus" />
  498. <result property="clubID" column="clubID" />
  499. <result property="agreeFlag" column="agreeFlag" />
  500. <result property="serviceProviderStatus" column="serviceProviderStatus" />
  501. <result property="serviceProviderID" column="serviceProviderID" />
  502. <result property="userMoney" column="userMoney" />
  503. <result property="ableUserMoney" column="ableUserMoney" />
  504. <result property="logoffTime" column="logoffTime" />
  505. <result property="appKey" column="appKey" />
  506. <result property="appSecret" column="appSecret" />
  507. <result property="scanFlag" column="scanFlag" />
  508. <result property="userBeans" column="userBeans" />
  509. <result property="guideFlag" column="guideFlag" />
  510. <result property="loginFailTime" column="loginFailTime" />
  511. <result property="tipStatus" column="tipStatus" />
  512. <result property="onlineMoney" column="onlineMoney" />
  513. </resultMap>
  514. <sql id="selectUserVo">
  515. select
  516. user.userID,
  517. user.userOrganizeID,
  518. user.account,
  519. user.mobile,
  520. user.bindMobile,
  521. user.userPermission,
  522. user.userIdentity,
  523. user.email,
  524. user.userName,
  525. user.realName,
  526. user.source,
  527. user.image,
  528. user.password,
  529. user.name,
  530. user.registerUserTypeID,
  531. user.manufacturerStatus,
  532. user.shopID,
  533. user.auditStatus,
  534. user.auditTime,
  535. user.auditNote,
  536. user.registerTime,
  537. user.registerIP,
  538. user.ipAddress,
  539. user.loginTime,
  540. user.loginIP,
  541. user.validFlag,
  542. user.clubStatus,
  543. user.clubID,
  544. user.agreeFlag,
  545. user.serviceProviderStatus,
  546. user.serviceProviderID,
  547. ifnull(user.userMoney,0) AS userMoney,
  548. ifnull(user.ableUserMoney,0) AS ableUserMoney,
  549. user.logoffTime,
  550. user.appKey,
  551. user.appSecret,
  552. user.scanFlag,
  553. user.userBeans,
  554. user.guideFlag,
  555. user.loginFailTime,
  556. user.tipStatus,
  557. ifnull(user.onlineMoney,0) AS onlineMoney
  558. </sql>
  559. <select id="getByUser" parameterType="CmUser" resultMap="UserResult">
  560. <include refid="selectUserVo"/>
  561. from user AS user
  562. <where>
  563. <if test="userID != null and userID != ''">
  564. and user.userID
  565. <if test="userID.toUpperCase().indexOf('=')==-1">
  566. = #{userID}
  567. </if>
  568. <if test="userID.toUpperCase().indexOf('=')!=-1">
  569. <if test="userID.toUpperCase().indexOf('NOT')!=-1"> not </if>
  570. <if test="userID.toUpperCase().indexOf('IN')!=-1"> in </if>
  571. <foreach item="userIDIn" collection="userID.substring(userID.toUpperCase().indexOf('=')+1,userID.length()).trim().split(',')" open="(" separator="," close=")">
  572. #{userIDIn}
  573. </foreach>
  574. </if>
  575. </if>
  576. <if test="userOrganizeID != null and userOrganizeID != ''">
  577. and user.userOrganizeID
  578. <if test="userOrganizeID.toUpperCase().indexOf('=')==-1">
  579. = #{userOrganizeID}
  580. </if>
  581. <if test="userOrganizeID.toUpperCase().indexOf('=')!=-1">
  582. <if test="userOrganizeID.toUpperCase().indexOf('NOT')!=-1"> not </if>
  583. <if test="userOrganizeID.toUpperCase().indexOf('IN')!=-1"> in </if>
  584. <foreach item="typeIn" collection="userOrganizeID.substring(userOrganizeID.toUpperCase().indexOf('=')+1,userOrganizeID.length()).trim().split(',')" open="(" separator="," close=")">
  585. #{typeIn}
  586. </foreach>
  587. </if>
  588. </if>
  589. <if test="account != null and account != ''"> and user.account = #{account}</if>
  590. <if test="mobile != null and mobile != ''"> and user.mobile = #{mobile}</if>
  591. <if test="bindMobile != null and bindMobile != ''"> and user.bindMobile = #{bindMobile}</if>
  592. <if test="userPermission != null "> and user.userPermission = #{userPermission}</if>
  593. <if test="userIdentity != null and userIdentity != ''">
  594. and user.userIdentity
  595. <if test="userIdentity.toUpperCase().indexOf('=')==-1">
  596. = #{userIdentity}
  597. </if>
  598. <if test="userIdentity.toUpperCase().indexOf('=')!=-1">
  599. <if test="userIdentity.toUpperCase().indexOf('NOT')!=-1"> not </if>
  600. <if test="userIdentity.toUpperCase().indexOf('IN')!=-1"> in </if>
  601. <foreach item="typeIn" collection="userIdentity.substring(userIdentity.toUpperCase().indexOf('=')+1,userIdentity.length()).trim().split(',')" open="(" separator="," close=")">
  602. #{typeIn}
  603. </foreach>
  604. </if>
  605. </if>
  606. <if test="email != null and email != ''"> and user.email = #{email}</if>
  607. <if test="userName != null and userName != ''"> and user.userName like concat('%', #{userName}, '%')</if>
  608. <if test="realName != null and realName != ''"> and user.realName like concat('%', #{realName}, '%')</if>
  609. <if test="source != null and source != ''"> and user.source = #{source}</if>
  610. <if test="image != null and image != ''"> and user.image = #{image}</if>
  611. <if test="password != null and password != ''"> and user.password = #{password}</if>
  612. <if test="name != null and name != ''"> and user.name like concat('%', #{name}, '%')</if>
  613. <if test="registerUserTypeID != null and registerUserTypeID != ''">
  614. and user.registerUserTypeID
  615. <if test="registerUserTypeID.toUpperCase().indexOf('=')==-1">
  616. = #{registerUserTypeID}
  617. </if>
  618. <if test="registerUserTypeID.toUpperCase().indexOf('=')!=-1">
  619. <if test="registerUserTypeID.toUpperCase().indexOf('NOT')!=-1"> not </if>
  620. <if test="registerUserTypeID.toUpperCase().indexOf('IN')!=-1"> in </if>
  621. <foreach item="typeIn" collection="registerUserTypeID.substring(registerUserTypeID.toUpperCase().indexOf('=')+1,registerUserTypeID.length()).trim().split(',')" open="(" separator="," close=")">
  622. #{typeIn}
  623. </foreach>
  624. </if>
  625. </if>
  626. <if test="manufacturerStatus != null "> and user.manufacturerStatus = #{manufacturerStatus}</if>
  627. <if test="shopID != null "> and user.shopID = #{shopID}</if>
  628. <if test="auditStatus != null and auditStatus != ''"> and user.auditStatus = #{auditStatus}</if>
  629. <if test="auditTime != null and auditTime != ''"> and user.auditTime = #{auditTime}</if>
  630. <if test="auditNote != null and auditNote != ''"> and user.auditNote = #{auditNote}</if>
  631. <if test="registerTime != null and registerTime != ''"> and user.registerTime = #{registerTime}</if>
  632. <if test="registerIP != null and registerIP != ''"> and user.registerIP = #{registerIP}</if>
  633. <if test="ipAddress != null and ipAddress != ''"> and user.ipAddress = #{ipAddress}</if>
  634. <if test="loginTime != null and loginTime != ''"> and user.loginTime = #{loginTime}</if>
  635. <if test="loginIP != null and loginIP != ''"> and user.loginIP = #{loginIP}</if>
  636. <if test="validFlag != null and validFlag != ''"> and user.validFlag = #{validFlag}</if>
  637. <if test="clubStatus != null "> and user.clubStatus = #{clubStatus}</if>
  638. <if test="clubID != null "> and user.clubID = #{clubID}</if>
  639. <if test="agreeFlag != null and agreeFlag != ''"> and user.agreeFlag = #{agreeFlag}</if>
  640. <if test="serviceProviderStatus != null "> and user.serviceProviderStatus = #{serviceProviderStatus}</if>
  641. <if test="serviceProviderID != null "> and user.serviceProviderID = #{serviceProviderID}</if>
  642. <if test="userMoney != null "> and user.userMoney = #{userMoney}</if>
  643. <if test="ableUserMoney != null "> and user.ableUserMoney = #{ableUserMoney}</if>
  644. <if test="logoffTime != null and logoffTime != ''"> and user.logoffTime = #{logoffTime}</if>
  645. <if test="appKey != null and appKey != ''"> and user.appKey = #{appKey}</if>
  646. <if test="appSecret != null and appSecret != ''"> and user.appSecret = #{appSecret}</if>
  647. <if test="scanFlag != null "> and user.scanFlag = #{scanFlag}</if>
  648. <if test="userBeans != null "> and user.userBeans = #{userBeans}</if>
  649. <if test="guideFlag != null "> and user.guideFlag = #{guideFlag}</if>
  650. <if test="loginFailTime != null "> and user.loginFailTime = #{loginFailTime}</if>
  651. <if test="tipStatus != null and tipStatus != ''"> and user.tipStatus = #{tipStatus}</if>
  652. <if test="onlineMoney != null "> and user.onlineMoney = #{onlineMoney}</if>
  653. </where>
  654. group by user.userID
  655. order by user.loginTime desc
  656. limit 0,1
  657. </select>
  658. <select id="findUserByMobile" resultMap="UserResult">
  659. <include refid="selectUserVo"/>
  660. FROM user user
  661. WHERE user.bindMobile=#{mobile}
  662. <if test="oldUserId !=null and oldUserId !=''">
  663. and user.userId!=#{oldUserId}
  664. </if>
  665. <if test="userIdentity !=null">
  666. and user.userIdentity=#{userIdentity}
  667. </if>
  668. limit 0,1
  669. </select>
  670. <select id="findAdminMobileList" parameterType="String" resultType="String">
  671. select
  672. cm_admin_mobile.mobile
  673. from cm_admin_mobile AS cm_admin_mobile
  674. <where>cm_admin_mobile.delFlag = 0 and cm_admin_mobile.enabledStatus = 1
  675. <if test="type != null and type != ''">and cm_admin_mobile.type = #{type}</if>
  676. </where>
  677. group by cm_admin_mobile.id
  678. order by cm_admin_mobile.createTime desc
  679. </select>
  680. <insert id="addWxUnion" parameterType="WxUnion">
  681. insert into wx_union
  682. <trim prefix="(" suffix=")" suffixOverrides=",">
  683. <if test="unionId != null and unionId != ''">unionId,</if>
  684. <if test="type != null and type == 1">
  685. appOpenid,
  686. </if>
  687. <if test="type != null and type == 2">
  688. heheOpenid,
  689. </if>
  690. <if test="type != null and type == 3">
  691. crmOpenid,
  692. </if>
  693. <if test="type != null and type == 4">
  694. miniProgramOpenId,
  695. </if>
  696. </trim>
  697. <trim prefix="values (" suffix=")" suffixOverrides=",">
  698. <if test="unionId != null and unionId != ''">#{unionId},</if>
  699. <if test="type != null">
  700. #{openid},
  701. </if>
  702. </trim>
  703. </insert>
  704. <update id="updateWxUnion" parameterType="WxUnion">
  705. update wx_union
  706. <trim prefix="SET" suffixOverrides=",">
  707. <if test="type != null and type == 1">
  708. appOpenid = #{openid},
  709. </if>
  710. <if test="type != null and type == 2">
  711. heheOpenid = #{openid},
  712. </if>
  713. <if test="type != null and type == 3">
  714. crmOpenid = #{openid},
  715. </if>
  716. <if test="type != null and type == 4">
  717. miniProgramOpenId = #{openid},
  718. </if>
  719. </trim>
  720. where unionId = #{unionId}
  721. </update>
  722. <select id="getByWxUnion" parameterType="WxUnion" resultType="WxUnion">
  723. select
  724. wx_union.unionId,
  725. wx_union.userId,
  726. wx_union.crmOpenid,
  727. wx_union.appOpenid,
  728. wx_union.miniProgramOpenId,
  729. wx_union.heheOpenid
  730. from wx_union AS wx_union
  731. <where>
  732. <if test="unionId != null and unionId != ''">
  733. and wx_union.unionId = #{unionId}
  734. </if>
  735. <if test="type != null and type == 1">
  736. and wx_union.appOpenid = #{openid}
  737. </if>
  738. <if test="type != null and type == 2">
  739. and wx_union.heheOpenid = #{openid}
  740. </if>
  741. <if test="type != null and type == 3">
  742. and wx_union.crmOpenid = #{openid}
  743. </if>
  744. <if test="type != null and type == 4">
  745. and wx_union.miniProgramOpenId = #{openid}
  746. </if>
  747. </where>
  748. limit 1
  749. </select>
  750. </mapper>