UserServiceDaoImplMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="userServiceDaoImpl">
  6. <resultMap type="com.java110.dto.user.Cust" id="custMap">
  7. <id column="custId" jdbcType="VARCHAR" property="custId"/>
  8. <result column="name" jdbcType="VARCHAR" property="name"/>
  9. <result column="email" jdbcType="VARCHAR" property="email"/>
  10. <result column="cellphone" jdbcType="VARCHAR" property="cellphone"/>
  11. <result column="realName" jdbcType="VARCHAR" property="realName"/>
  12. <result column="sex" jdbcType="VARCHAR" property="sex"/>
  13. <result column="password" jdbcType="VARCHAR" property="password"/>
  14. <result column="lanId" jdbcType="VARCHAR" property="lanId"/>
  15. <result column="custAdress" jdbcType="VARCHAR" property="custAdress"/>
  16. <result column="custType" jdbcType="VARCHAR" property="custType"/>
  17. <result column="openId" jdbcType="VARCHAR" property="openId"/>
  18. <!-- 一对多关系 -->
  19. <!-- <collection property="stus" resultMap="Student.StudentResult"></collection> -->
  20. <collection property="custAttrs" javaType="com.java110.dto.user.CustAttr">
  21. <id property="custId" column="custId"/>
  22. <result property="attrCd" column="attrCd"/>
  23. <result property="value" column="value"/>
  24. </collection>
  25. </resultMap>
  26. <!--根据用户Id查询用户角色
  27. <select id="findRolesByUserId" resultType="SysRole">
  28. SELECT
  29. r.*
  30. FROM
  31. t_role r,
  32. t_user_role ur
  33. WHERE ur.uid = #{userId}
  34. AND ur.roleId = r.roleId
  35. AND ur.status_cd = '1'
  36. </select>
  37. -->
  38. <!--保存数据至过程表 bo_cust 中 -->
  39. <insert id="saveDataToBoCust" parameterType="com.java110.dto.user.BoCust">
  40. <![CDATA[
  41. insert into bo_cust(boId,custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,state)
  42. values(#{boId},#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{state})
  43. ]]>
  44. </insert>
  45. <!-- 保存数据至过程表bo_cust_attr 中-->
  46. <insert id="saveDataToBoCustAttr" parameterType="com.java110.dto.user.BoCustAttr">
  47. <![CDATA[
  48. insert into bo_cust_attr(boId,custId,attrCd,value,state)
  49. values(#{boId},#{custId},#{attrCd},#{value},#{state})
  50. ]]>
  51. </insert>
  52. <!-- 保存 实例客户信息 cust -->
  53. <insert id="saveDataToCust" parameterType="com.java110.dto.user.Cust">
  54. <![CDATA[
  55. insert into cust(custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,status_cd)
  56. values(#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{status_cd})
  57. ]]>
  58. </insert>
  59. <!-- 删除实例客户信息 cust -->
  60. <insert id="deleteDataToCust" parameterType="com.java110.dto.user.Cust">
  61. <![CDATA[
  62. delete * from cust c where c.custId = #{custId}
  63. ]]>
  64. </insert>
  65. <!-- 保存 实例客户属性信息 cust_attr -->
  66. <insert id="saveDataToCustAttr" parameterType="com.java110.dto.user.CustAttr">
  67. <![CDATA[
  68. insert into cust_attr(custId,attrCd,value,status_cd)
  69. values(#{custId},#{attrCd},#{value},#{status_cd})
  70. ]]>
  71. </insert>
  72. <!-- 删除实例客户信息 cust -->
  73. <update id="deleteDataToCustAttr" parameterType="com.java110.dto.user.CustAttr">
  74. delete * from cust_attr ct where 1=1
  75. <if test="custId != null and custId != ''">
  76. and ct.custId = #{custId}
  77. </if>
  78. <if test="attrCd != null and attrCd != ''">
  79. and ct.attrCd = #{attrCd}
  80. </if>
  81. </update>
  82. <!--根据客户ID 查询客户信息,其中包括 cust 和custAttr 数据-->
  83. <select id="queryDataToCust" parameterType="com.java110.dto.user.Cust" resultMap="custMap">
  84. select c.custId,c.name,c.email,c.cellphone,c.realName,c.sex,c.password,c.lanId,c.custAdress,c.custType,c.openId,
  85. ca.custId,ca.attrCd,ca.value
  86. from cust c, cust_attr ca where c.custId= ca.custId
  87. <if test="custId != null and custId != ''">
  88. and c.custId = #{custId}
  89. </if>
  90. <if test="versionId != null and versionId != ''">
  91. and c.versionId = #{versionId}
  92. </if>
  93. and c.status_cd = '0'
  94. </select>
  95. <!-- 查询客户过程数据 -->
  96. <select id="queryBoCust" parameterType="com.java110.dto.user.BoCust" resultType="com.java110.dto.user.BoCust">
  97. select
  98. bc.boId,bc.custId,bc.name,bc.email,bc.cellphone,bc.realName,bc.sex,bc.password,bc.lanId,bc.custAdress,bc.custType,bc.openId,bc.create_dt
  99. from bo_cust bc where 1=1
  100. <if test="boId != null and boId != ''">
  101. and bc.boId = #{boId}
  102. </if>
  103. <if test="custId != null and custId != ''">
  104. and bc.custId = #{custId}
  105. </if>
  106. <if test="versionId != null and versionId != ''">
  107. and c.versionId = #{versionId}
  108. </if>
  109. and bc.state in ('ADD','DEL','KIP')
  110. <if test="create_dt != null and create_dt != ''">
  111. order by bc.create_dt desc
  112. </if>
  113. </select>
  114. <!-- 查询客户属性过程表-->
  115. <select id="queryBoCustAttr" parameterType="com.java110.dto.user.BoCustAttr"
  116. resultType="com.java110.dto.user.BoCustAttr">
  117. select bca.boId,bca.custId,bca.attrCd,bca.value,bca.state,bca.create_dt from bo_cust_attr bca where 1=1
  118. <if test="boId !=null and boId != ''">
  119. and bca.boId = #{boId}
  120. </if>
  121. <if test="custId != null and custId != ''">
  122. and bca.custId = #{custId}
  123. </if>
  124. <if test="versionId != null and versionId != ''">
  125. and bca.versionId = #{versionId}
  126. </if>
  127. <if test="create_dt != null and create_dt != ''">
  128. order by bca.create_dt desc
  129. </if>
  130. </select>
  131. <!-- 查询客户属性信息 -->
  132. <select id="queryDataToCustAttr" parameterType="com.java110.dto.user.CustAttr"
  133. resultType="com.java110.dto.user.CustAttr">
  134. select * from cust_attr ca where 1=1
  135. <if test="custId != null and custId != ''">
  136. and ca.custId = #{custId}
  137. </if>
  138. <if test="versionId != null and versionId != ''">
  139. and ca.versionId = #{versionId}
  140. </if>
  141. <if test="attrCd != null and attrCd != ''">
  142. and ca.attrCd = #{attrCd}
  143. </if>
  144. and status_cd = '0'
  145. </select>
  146. <!-- 保存用户信息 -->
  147. <insert id="saveBusinessUserInfo" parameterType="map">
  148. insert into business_user(b_id,user_id,name,email,address,password,location_cd,age,sex,tel,level_cd,operate)
  149. values(#{bId},#{userId},#{name},#{email},#{address},#{password},#{locationCd},#{age},#{sex},#{tel},#{levelCd},#{operate})
  150. </insert>
  151. <!-- 保存用户属性 -->
  152. <insert id="saveBusinessUserAttr" parameterType="map">
  153. insert into business_user_attr(b_id,user_id,attr_id,spec_cd,value,operate)
  154. values(#{bId},#{userId},#{attrId},#{specCd},#{value},#{operate})
  155. </insert>
  156. <!-- 实例数据 -->
  157. <insert id="saveUserInfoInstance" parameterType="map">
  158. insert into u_user(user_id,name,email,address,password,location_cd,age,sex,tel,level_cd,b_id,status_cd)
  159. select
  160. bu.user_id,bu.name,bu.email,bu.address,bu.password,bu.location_cd,bu.age,bu.sex,bu.tel,bu.level_cd,bu.b_id,'0'
  161. from business_user bu where bu.operate = 'ADD' and bu.b_id=#{b_id}
  162. </insert>
  163. <insert id="saveUserAttrInstance" parameterType="map">
  164. insert into u_user_attr(attr_id,user_id,spec_cd,value,b_id,status_cd)
  165. select bua.attr_id,bua.user_id,bua.spec_cd,bua.value,bua.b_id,'0' from business_user_attr bua where
  166. bua.operate='ADD' and bua.b_id=#{b_id}
  167. </insert>
  168. <update id="updateUserInfoInstance" parameterType="map">
  169. update u_user u set u.status_cd = #{statusCd}
  170. <if test="newBId != null and newBId != ''">
  171. ,u.b_id = #{newBId}
  172. </if>
  173. <if test="name !=null and name != ''">
  174. ,u.name= #{name}
  175. </if>
  176. <if test="email !=null and email != ''">
  177. ,u.email= #{email}
  178. </if>
  179. <if test="address !=null and address != ''">
  180. ,u.address= #{address}
  181. </if>
  182. <if test="password !=null and password != ''">
  183. ,u.password= #{password}
  184. </if>
  185. <if test="locationCd !=null and locationCd != ''">
  186. ,u.location_cd= #{locationCd}
  187. </if>
  188. <if test="age !=null and age != ''">
  189. ,u.age= #{age}
  190. </if>
  191. <if test="sex !=null and sex != ''">
  192. ,u.sex= #{sex}
  193. </if>
  194. <if test="tel !=null and tel != ''">
  195. ,u.tel= #{tel}
  196. </if>
  197. <if test="score !=null and score != ''">
  198. ,u.score= #{score}
  199. </if>
  200. where 1 = 1
  201. <if test="bId != null and bId != ''">
  202. and u.b_id = #{bId}
  203. </if>
  204. <if test="userId != null and userId !=''">
  205. and u.user_id = #{userId}
  206. </if>
  207. <if test="attrId != null and attrId != ''">
  208. and u.attr_id = #{attrId}
  209. </if>
  210. </update>
  211. <update id="updateUserAttrInstance" parameterType="map">
  212. update u_user_attr ua set ua.status_cd = #{statusCd} where 1 = 1
  213. <if test="bId != null and bId != ''">
  214. and ua.b_id = #{bId}
  215. </if>
  216. <if test="userId != null and userId !=''">
  217. and ua.user_id = #{userId}
  218. </if>
  219. </update>
  220. <!-- 查询用户信息 Business -->
  221. <select id="queryBusinessUserInfo" parameterType="map" resultType="map">
  222. select u.user_id,u.name,u.email,u.address,u.password,u.location_cd,
  223. u.age,u.sex,u.tel,u.level_cd,u.b_id,u.operate
  224. from business_user u where 1 = 1
  225. <if test="operate != null and operate != ''">
  226. and u.operate = #{operate}
  227. </if>
  228. <if test="bId != null and bId !=''">
  229. and u.b_id = #{bId}
  230. </if>
  231. <if test="userId != null and userId != ''">
  232. and u.user_id = #{userId}
  233. </if>
  234. </select>
  235. <!-- 查询用户属性信息 Business-->
  236. <select id="queryBusinessUserInfoAttrs" parameterType="map" resultType="map">
  237. select u.attr_id,u.user_id,u.spec_cd,u.value,u.b_id,u.operate
  238. from business_user_attr u where 1 = 1
  239. <if test="operate != null and operate != ''">
  240. and u.operate = #{operate}
  241. </if>
  242. <if test="bId != null and bId !=''">
  243. and u.b_id = #{bId}
  244. </if>
  245. <if test="userId != null and userId != ''">
  246. and u.user_id = #{userId}
  247. </if>
  248. <if test="attrId != null and attrId != ''">
  249. and u.attr_id = #{attrId}
  250. </if>
  251. </select>
  252. <!-- 查询用户信息 -->
  253. <select id="queryUserInfo" parameterType="map" resultType="map">
  254. select u.user_id, u.user_id userId,u.name,u.name
  255. userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
  256. u.age,u.sex,u.tel,u.level_cd,u.b_id
  257. from u_user u where 1= 1
  258. <if test="bId != null and bId !=''">
  259. and u.b_id = #{bId}
  260. </if>
  261. <if test="userId != null and userId != ''">
  262. and u.user_id = #{userId}
  263. </if>
  264. <if test="statusCd !=null and statusCd != ''">
  265. and u.status_cd = #{statusCd}
  266. </if>
  267. <if test="userIds != null and userIds != null">
  268. and u.user_id in
  269. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  270. #{item}
  271. </foreach>
  272. </if>
  273. </select>
  274. <!-- 查询用户属性信息 -->
  275. <select id="queryUserInfoAttrs" parameterType="map" resultType="map">
  276. select u.attr_id,u.user_id,u.spec_cd,u.value,u.b_id,
  277. u.attr_id attrId,u.user_id userId,u.spec_cd specCd,u.b_id bId
  278. from u_user_attr u where u.status_cd = '0'
  279. <if test="bId != null and bId !=''">
  280. and u.b_id = #{bId}
  281. </if>
  282. <if test="userId != null and userId != ''">
  283. and u.user_id = #{userId}
  284. </if>
  285. <if test="attrId != null and attrId != ''">
  286. and u.attr_id = #{attrId}
  287. </if>
  288. <if test="specCd != null and specCd != ''">
  289. and u.spec_cd = #{specCd}
  290. </if>
  291. </select>
  292. <!--保存用户地址信息 add by wuxw 2018-06-29 -->
  293. <insert id="saveBusinessUserAddress" parameterType="map">
  294. insert into business_user_address(address_id,b_id,user_id,tel,postal_code,address,is_default,operate)
  295. values(#{addressId},#{bId},#{userId},#{tel},#{postalCode},#{address},#{isDefault},#{operate})
  296. </insert>
  297. <!-- 查询用户地址信息 add by wuxw 2018-06-29-->
  298. <select id="queryBusinessUserAddress" parameterType="map" resultType="map">
  299. select ua.address_id,ua.b_id,ua.user_id,ua.tel,ua.postal_code,ua.address,ua.is_default,ua.operate
  300. from business_user_address ua where 1 = 1
  301. <if test="operate != null and operate != ''">
  302. and ua.operate = #{operate}
  303. </if>
  304. <if test="bId != null and bId !=''">
  305. and ua.b_id = #{bId}
  306. </if>
  307. <if test="userId != null and userId != ''">
  308. and ua.user_id = #{userId}
  309. </if>
  310. </select>
  311. <!-- 保存用户地址 Business 数据到 Instance add by wuxw 2018-06-29 -->
  312. <insert id="saveUserAddressInstance" parameterType="map">
  313. insert into u_user_address(address_id,b_id,user_id,tel,postal_code,address,is_default,status_cd)
  314. select ua.address_id,ua.b_id,ua.user_id,ua.tel,ua.postal_code,ua.address,ua.is_default,'0'
  315. from business_user_address ua where 1 = 1
  316. ua.operate = 'ADD' and ua.b_id=#{b_id}
  317. </insert>
  318. <!-- 作废用户地址信息数据 add by wuxw 2018-06-29-->
  319. <update id="updateUserAddressInstance" parameterType="map">
  320. update u_user_address ua set ua.status_cd = #{statusCd} where 1 = 1
  321. <if test="bId != null and bId != ''">
  322. and ua.b_id = #{bId}
  323. </if>
  324. <if test="userId != null and userId !=''">
  325. and ua.user_id = #{userId}
  326. </if>
  327. <if test="addressId != null and addressId != ''">
  328. and ua.address_id = #{addressId}
  329. </if>
  330. </update>
  331. <!--保存用户打标信息 add by wuxw 2018-06-29 -->
  332. <insert id="saveBusinessUserTag" parameterType="map">
  333. insert into business_user_tag(tag_id,b_id,user_id,tag_cd,remark,operate)
  334. values(#{tagId},#{bId},#{userId},#{tagCd},#{remark},#{operate})
  335. </insert>
  336. <!-- 查询用户地址信息 add by wuxw 2018-06-29-->
  337. <select id="queryBusinessUserTag" parameterType="map" resultType="map">
  338. select ut.tag_id,ut.b_id,ut.user_id,ut.tag_cd,ut.remark,ut.operate
  339. from business_user_tag ut where 1 = 1
  340. <if test="operate != null and operate != ''">
  341. and ut.operate = #{operate}
  342. </if>
  343. <if test="bId != null and bId !=''">
  344. and ut.b_id = #{bId}
  345. </if>
  346. <if test="userId != null and userId != ''">
  347. and ut.user_id = #{userId}
  348. </if>
  349. </select>
  350. <!-- 保存用户地址 Business 数据到 Instance add by wuxw 2018-06-29 -->
  351. <insert id="saveUserTagInstance" parameterType="map">
  352. insert into u_user_tag(tag_id,b_id,user_id,tag_cd,remark,status_cd)
  353. select ut.tag_id,ut.b_id,ut.user_id,ut.tag_cd,ut.remark,'0'
  354. from business_user_tag ut where 1 = 1
  355. ut.operate = 'ADD' and ut.b_id=#{b_id}
  356. </insert>
  357. <!-- 作废用户地址信息数据 add by wuxw 2018-06-29-->
  358. <update id="updateUserTagInstance" parameterType="map">
  359. update u_user_tag ut set ut.status_cd = #{statusCd} where 1 = 1
  360. <if test="bId != null and bId != ''">
  361. and ut.b_id = #{bId}
  362. </if>
  363. <if test="userId != null and userId !=''">
  364. and ut.user_id = #{userId}
  365. </if>
  366. <if test="addressId != null and addressId != ''">
  367. and ut.address_id = #{tagId}
  368. </if>
  369. </update>
  370. <!--保存用户证件信息 add by wuxw 2018-06-29 -->
  371. <insert id="saveBusinessUserCredentials" parameterType="map">
  372. insert into business_user_credentials(credentials_id,b_id,user_id,credentials_cd,value,operate)
  373. values(#{credentialsId},#{bId},#{userId},#{credentialsCd},#{value},#{operate})
  374. </insert>
  375. <!-- 查询用户地址信息 add by wuxw 2018-06-29-->
  376. <select id="queryBusinessUserCredentials" parameterType="map" resultType="map">
  377. select uc.credentials_id,uc.b_id,uc.user_id,uc.credentials_cd,uc.value,uc.operate
  378. from business_user_credentials uc where 1 = 1
  379. <if test="operate != null and operate != ''">
  380. and uc.operate = #{operate}
  381. </if>
  382. <if test="bId != null and bId !=''">
  383. and uc.b_id = #{bId}
  384. </if>
  385. <if test="userId != null and userId != ''">
  386. and uc.user_id = #{userId}
  387. </if>
  388. </select>
  389. <!-- 保存用户地址 Business 数据到 Instance add by wuxw 2018-06-29 -->
  390. <insert id="saveUserCredentialsInstance" parameterType="map">
  391. insert into u_user_credentials(credentials_id,b_id,user_id,credentials_cd,value,status_cd)
  392. select uc.credentials_id,uc.b_id,uc.user_id,uc.credentials_cd,uc.value,'0'
  393. from business_user_credentials uc where 1 = 1
  394. uc.operate = 'ADD' and uc.b_id=#{b_id}
  395. </insert>
  396. <!-- 作废用户地址信息数据 add by wuxw 2018-06-29-->
  397. <update id="updateUserCredentialsInstance" parameterType="map">
  398. update u_user_credentials uc set uc.status_cd = #{statusCd} where 1 = 1
  399. <if test="bId != null and bId != ''">
  400. and uc.b_id = #{bId}
  401. </if>
  402. <if test="userId != null and userId !=''">
  403. and uc.user_id = #{userId}
  404. </if>
  405. <if test="addressId != null and addressId != ''">
  406. and uc.credentials_id = #{credentialsId}
  407. </if>
  408. </update>
  409. <!-- 查询员工总量 -->
  410. <select id="getStaffCount" parameterType="Map" resultType="Map">
  411. <if test="orgIds != null and orgIds.length > 0">
  412. select count(*) count from(
  413. </if>
  414. select count(1) count
  415. from u_user u
  416. inner join s_store_user su on su.user_id = u.user_id
  417. <if test="(orgId !=null and orgId != '')||(orgIds != null and orgIds.length > 0)">
  418. left join u_org_staff_rel uosr on u.user_id = uosr.staff_id and uosr.status_cd = '0'
  419. left join u_org uo on uosr.org_id = uo.org_id and uo.status_cd = '0'
  420. </if>
  421. where u.level_cd = '01'
  422. <if test="storeId !=null and storeId != ''">
  423. and su.store_id = #{storeId}
  424. </if>
  425. <if test="orgId !=null and orgId != ''">
  426. and uosr.org_id = #{orgId}
  427. </if>
  428. and u.status_cd = '0'
  429. <if test="tel !=null and tel != ''">
  430. and u.tel= #{tel}
  431. </if>
  432. <if test="name !=null and name != ''">
  433. and u.name like concat('%',#{name},'%')
  434. </if>
  435. <if test="nameLike !=null and nameLike != ''">
  436. and u.name like concat('%',#{nameLike},'%')
  437. </if>
  438. <if test="staffName !=null and staffName != ''">
  439. and u.name like concat('%',#{staffName},'%')
  440. </if>
  441. <if test="staffId != null and staffId !=''">
  442. and u.user_id = #{staffId}
  443. </if>
  444. <if test="orgId !=null and orgId != ''">
  445. and uo.org_id = #{orgId}
  446. </if>
  447. <if test="bId != null and bId !=''">
  448. and u.b_id = #{bId}
  449. </if>
  450. <if test="userIds != null and userIds != null">
  451. and u.user_id in
  452. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  453. #{item}
  454. </foreach>
  455. </if>
  456. <if test="orgIds != null and orgIds.length > 0">
  457. and uosr.org_id in
  458. <foreach collection="orgIds" item="item" open="(" close=")" separator=",">
  459. #{item}
  460. </foreach>
  461. and uosr.status_cd =0
  462. GROUP BY u.user_id
  463. </if>
  464. <if test="orgIds != null and orgIds.length > 0">
  465. )a
  466. </if>
  467. </select>
  468. <!-- 查询员工总量 -->
  469. <select id="getStaffs" parameterType="Map" resultType="Map">
  470. select u.user_id, u.user_id userId,u.name,u.name
  471. userName,u.email,u.address,u.location_cd,u.location_cd locationCd,
  472. u.age,u.sex,u.tel,u.level_cd levelCd,u.b_id,su.rel_cd relCd,td.name relCdName
  473. <if test="orgId !=null and orgId != ''">
  474. ,uo.org_id orgId,uo.org_name,uo.org_name orgName,uosr.store_id storeId,uosr.rel_id relId
  475. </if>
  476. from
  477. u_user u
  478. inner join s_store_user su on su.user_id = u.user_id
  479. left join t_dict td on su.rel_cd = td.status_cd and td.table_name='s_store_user' and td.table_columns='rel_cd'
  480. <if test="(orgId !=null and orgId != '')||(orgIds != null and orgIds.length > 0)">
  481. left join u_org_staff_rel uosr on u.user_id = uosr.staff_id and uosr.status_cd = '0'
  482. left join u_org uo on uosr.org_id = uo.org_id and uo.status_cd = '0'
  483. </if>
  484. where u.level_cd = '01'
  485. <if test="storeId !=null and storeId != ''">
  486. and su.store_id = #{storeId}
  487. </if>
  488. <if test="orgId !=null and orgId != ''">
  489. and uosr.org_id = #{orgId}
  490. </if>
  491. and u.status_cd = '0'
  492. <if test="tel !=null and tel != ''">
  493. and u.tel= #{tel}
  494. </if>
  495. <if test="name !=null and name != ''">
  496. and u.name like concat('%',#{name},'%')
  497. </if>
  498. <if test="nameLike !=null and nameLike != ''">
  499. and u.name like concat('%',#{nameLike},'%')
  500. </if>
  501. <if test="staffName !=null and staffName != ''">
  502. and u.name like concat('%',#{staffName},'%')
  503. </if>
  504. <if test="staffId != null and staffId !=''">
  505. and u.user_id = #{staffId}
  506. </if>
  507. <if test="orgId !=null and orgId != ''">
  508. and uo.org_id = #{orgId}
  509. </if>
  510. <if test="bId != null and bId !=''">
  511. and u.b_id = #{bId}
  512. </if>
  513. <if test="userIds != null and userIds != null">
  514. and u.user_id in
  515. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  516. #{item}
  517. </foreach>
  518. </if>
  519. <if test="orgIds != null and orgIds.length > 0">
  520. and uosr.org_id in
  521. <foreach collection="orgIds" item="item" open="(" close=")" separator=",">
  522. #{item}
  523. </foreach>
  524. and uosr.status_cd =0
  525. GROUP BY u.user_id,u.name,u.email,u.address,u.location_cd,
  526. u.age,u.sex,u.tel,u.level_cd ,u.b_id,su.rel_cd ,td.name
  527. ,uo.org_id,uo.org_name,uosr.store_id,uosr.rel_id
  528. </if>
  529. order by u.create_time desc
  530. <if test="page != -1 and page != null ">
  531. limit #{page}, #{row}
  532. </if>
  533. </select>
  534. <!-- 查询用户 -->
  535. <select id="getUsers" parameterType="Map" resultType="Map">
  536. select u.user_id, u.user_id userId,u.name,u.name
  537. userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
  538. u.age,u.sex,u.tel,u.level_cd,u.b_id,u.level_cd levelCd,u.score
  539. from u_user u
  540. <if test="openId != null and openId !=''">
  541. ,u_user_attr ua
  542. </if>
  543. <if test="key != null and key !=''">
  544. ,u_user_attr ub
  545. </if>
  546. <if test="unionId != null and unionId !=''">
  547. ,u_user_attr ua
  548. </if>
  549. where 1= 1
  550. <if test="openId != null and openId != ''">
  551. and u.user_id = ua.user_id
  552. and ua.spec_cd in ('100201911001','100201911003')
  553. and ua.value = #{openId}
  554. and ua.status_cd = '0'
  555. </if>
  556. <if test="unionId != null and unionId != ''">
  557. and u.user_id = ua.user_id
  558. and ua.spec_cd = '100201911002'
  559. and ua.value = #{unionId}
  560. and ua.status_cd = '0'
  561. </if>
  562. <if test="key != null and key != ''">
  563. and u.user_id = ub.user_id
  564. and ub.spec_cd = '100202061602'
  565. and ub.value = #{key}
  566. and ub.status_cd = '0'
  567. </if>
  568. <if test="bId != null and bId !=''">
  569. and u.b_id = #{bId}
  570. </if>
  571. <if test="userId != null and userId != ''">
  572. and u.user_id = #{userId}
  573. </if>
  574. <if test="statusCd !=null and statusCd != ''">
  575. and u.status_cd = #{statusCd}
  576. </if>
  577. <if test="userIds != null and userIds != null">
  578. and u.user_id in
  579. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  580. #{item}
  581. </foreach>
  582. </if>
  583. <if test="name !=null and name != ''">
  584. and u.name= #{name}
  585. </if>
  586. <if test="userName !=null and userName != ''">
  587. and u.name= #{userName}
  588. </if>
  589. <if test="email !=null and email != ''">
  590. and u.email= #{email}
  591. </if>
  592. <if test="password !=null and password != ''">
  593. and u.password= #{password}
  594. </if>
  595. <if test="locationCd !=null and locationCd != ''">
  596. and u.location_cd= #{locationCd}
  597. </if>
  598. <if test="age !=null and age != ''">
  599. and u.age= #{age}
  600. </if>
  601. <if test="sex !=null and sex != ''">
  602. and u.sex= #{sex}
  603. </if>
  604. <if test="tel !=null and tel != ''">
  605. and u.tel= #{tel}
  606. </if>
  607. <if test="levelCd !=null and levelCd != ''">
  608. and u.level_cd= #{levelCd}
  609. </if>
  610. <if test="levelCds != null">
  611. and u.level_cd in
  612. <foreach collection="levelCds" item="item" open="(" close=")" separator=",">
  613. #{item}
  614. </foreach>
  615. </if>
  616. <if test='userFlag !=null and userFlag =="1"'>
  617. and u.level_cd != '02'
  618. </if>
  619. order by u.create_time desc
  620. <if test="page != -1 and page != null ">
  621. limit #{page}, #{row}
  622. </if>
  623. </select>
  624. <select id="getUserCount" parameterType="Map" resultType="Map">
  625. select count(1) count
  626. from u_user u
  627. <if test="openId != null and openId !=''">
  628. ,u_user_attr ua
  629. </if>
  630. <if test="unionId != null and unionId !=''">
  631. ,u_user_attr ua
  632. </if>
  633. where 1= 1
  634. <if test="openId != null and openId != ''">
  635. and u.user_id = ua.user_id
  636. and ua.spec_cd in ('100201911001','100201911003')
  637. and ua.value = #{openId}
  638. and ua.status_cd = '0'
  639. </if>
  640. <if test="unionId != null and unionId != ''">
  641. and u.user_id = ua.user_id
  642. and ua.spec_cd = '100201911002'
  643. and ua.value = #{unionId}
  644. and ua.status_cd = '0'
  645. </if>
  646. <if test="bId != null and bId !=''">
  647. and u.b_id = #{bId}
  648. </if>
  649. <if test="userId != null and userId != ''">
  650. and u.user_id = #{userId}
  651. </if>
  652. <if test="statusCd !=null and statusCd != ''">
  653. and u.status_cd = #{statusCd}
  654. </if>
  655. <if test="userIds != null and userIds != null">
  656. and u.user_id in
  657. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  658. #{item}
  659. </foreach>
  660. </if>
  661. </select>
  662. <!-- 查询用户密码 -->
  663. <select id="getUserHasPwd" parameterType="Map" resultType="Map">
  664. select u.user_id, u.user_id userId,u.name,u.name
  665. userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
  666. u.age,u.sex,u.tel,u.level_cd levelCd,u.b_id,u.password
  667. from u_user u
  668. <if test="openId != null and openId !=''">
  669. ,u_user_attr ua
  670. </if>
  671. <if test="unionId != null and unionId !=''">
  672. ,u_user_attr ua
  673. </if>
  674. where 1= 1
  675. <if test="openId != null and openId != ''">
  676. and u.user_id = ua.user_id
  677. and ua.spec_cd = '100201911001'
  678. and ua.value = #{openId}
  679. and ua.status_cd = '0'
  680. </if>
  681. <if test="unionId != null and unionId != ''">
  682. and u.user_id = ua.user_id
  683. and ua.spec_cd = '100201911002'
  684. and ua.value = #{unionId}
  685. and ua.status_cd = '0'
  686. </if>
  687. <if test="bId != null and bId !=''">
  688. and u.b_id = #{bId}
  689. </if>
  690. <if test="userId != null and userId != ''">
  691. and u.user_id = #{userId}
  692. </if>
  693. <if test="statusCd !=null and statusCd != ''">
  694. and u.status_cd = #{statusCd}
  695. </if>
  696. </select>
  697. </mapper>