CompanyUserMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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="com.fs.company.mapper.CompanyUserMapper">
  6. <resultMap type="CompanyUser" id="CompanyUserResult">
  7. <result property="userId" column="user_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="deptId" column="dept_id" />
  10. <result property="userName" column="user_name" />
  11. <result property="nickName" column="nick_name" />
  12. <result property="userType" column="user_type" />
  13. <result property="email" column="email" />
  14. <result property="phonenumber" column="phonenumber" />
  15. <result property="sex" column="sex" />
  16. <result property="avatar" column="avatar" />
  17. <result property="idCard" column="id_card" />
  18. <result property="password" column="password" />
  19. <result property="status" column="status" />
  20. <result property="delFlag" column="del_flag" />
  21. <result property="loginIp" column="login_ip" />
  22. <result property="loginDate" column="login_date" />
  23. <result property="createBy" column="create_by" />
  24. <result property="createTime" column="create_time" />
  25. <result property="updateBy" column="update_by" />
  26. <result property="updateTime" column="update_time" />
  27. <result property="token" column="token" />
  28. <result property="remark" column="remark" />
  29. <result property="openId" column="open_id" />
  30. <result property="qrCodeWeixin" column="qr_code_weixin" />
  31. <result property="qrCodeWecom" column="qr_code_wecom" />
  32. <result property="jpushId" column="jpush_id" />
  33. <result property="firstchar" column="firstchar" />
  34. <result property="postName" column="post_name" />
  35. <result property="deptName" column="dept_name" />
  36. <result property="qwUserId" column="qw_user_id" />
  37. <result property="qwStatus" column="qw_status" />
  38. <result property="voicePrintUrl" column="voice_print_url" />
  39. <result property="addressId" column="address_id" />
  40. <result property="domain" column="domain" />
  41. <result property="isAudit" column="is_audit" />
  42. <result property="isNeedRegisterMember" column="is_need_register_member" />
  43. <result property="isAllowedAllRegister" column="is_allowed_all_register" />
  44. <result property="doctorId" column="doctor_id" />
  45. <result property="bindCompanyUserId" column="bind_company_user_id" />
  46. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  47. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  48. </resultMap>
  49. <resultMap id="CompanyUserQwListVOResult" type="com.fs.company.vo.CompanyUserQwListVO">
  50. <id property="userId" column="user_id"/>
  51. <result property="userName" column="user_name"/>
  52. <result property="nickName" column="nick_name"/>
  53. <result property="companyId" column="company_id"/>
  54. <result property="status" column="status"/>
  55. <result property="qwStatus" column="qw_status"/>
  56. <result property="qwUserId" column="qw_user_id"/>
  57. <result property="phonenumber" column="phonenumber"/>
  58. <result property="createTime" column="create_time"/>
  59. <result property="deptId" column="dept_id"/>
  60. <result property="deptName" column="dept_name"/>
  61. <result property="qrCodeWeixin" column="qr_code_weixin"/>
  62. <result property="postName" column="post_name"/>
  63. <result property="qrCodeWecom" column="qr_code_wecom"/>
  64. <result property="jpushId" column="jpush_id"/>
  65. <result property="callerNo" column="caller_no"/>
  66. <result property="isNeedRegisterMember" column="is_need_register_member" />
  67. <result property="isAllowedAllRegister" column="is_allowed_all_register" />
  68. <collection property="roleNames" ofType="java.lang.String" javaType="java.util.ArrayList"
  69. select="selectUserRoles" column="user_id"/>
  70. </resultMap>
  71. <resultMap id="deptResult" type="CompanyDept">
  72. <id property="deptId" column="dept_id"/>
  73. <result property="parentId" column="parent_id"/>
  74. <result property="deptName" column="dept_name"/>
  75. <result property="orderNum" column="order_num"/>
  76. <result property="leader" column="leader"/>
  77. <result property="status" column="dept_status"/>
  78. </resultMap>
  79. <resultMap id="RoleResult" type="CompanyRole">
  80. <id property="roleId" column="role_id" />
  81. <result property="roleName" column="role_name" />
  82. <result property="roleKey" column="role_key" />
  83. <result property="roleSort" column="role_sort" />
  84. <result property="dataScope" column="data_scope" />
  85. <result property="status" column="role_status" />
  86. </resultMap>
  87. <select id="selectCompanyUserQwListVO" resultMap="CompanyUserQwListVOResult">
  88. select
  89. u.user_id, u.user_name, u.nick_name, u.company_id, u.status,
  90. u.qw_status, u.phonenumber, u.create_time, u.dept_id,
  91. u.qr_code_weixin, u.user_type, u.qr_code_wecom, u.jpush_id,
  92. u.is_need_register_member,u.is_allowed_all_register,
  93. u.avatar,u.address_id,
  94. u.qw_user_id,
  95. d.dept_name,
  96. d.leader
  97. from
  98. company_user u
  99. left join
  100. company_dept d on u.dept_id = d.dept_id
  101. where
  102. u.del_flag = '0'
  103. <if test="userId != null ">
  104. AND u.user_id = #{userId}
  105. </if>
  106. <if test="userName != null and userName != ''">
  107. AND u.user_name like concat('%', #{userName}, '%')
  108. </if>
  109. <if test="nickName != null and nickName != ''">
  110. AND u.nick_name like concat( #{nickName}, '%')
  111. </if>
  112. <if test="companyId != null and companyId != ''">
  113. AND u.company_id = #{companyId}
  114. </if>
  115. <if test="status != null and status != ''">
  116. AND u.status = #{status}
  117. </if>
  118. <if test="qwStatus != null">
  119. AND u.qw_status = #{qwStatus}
  120. </if>
  121. <if test="phonenumber != null and phonenumber != ''">
  122. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  123. </if>
  124. <if test="beginTime != null and beginTime != ''">
  125. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  126. </if>
  127. <if test="endTime != null and endTime != ''">
  128. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  129. </if>
  130. <if test="deptId != null and deptId != 0">
  131. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  132. </if>
  133. <!-- 数据范围过滤 -->
  134. ${params.dataScope}
  135. </select>
  136. <!-- 角色子查询 -->
  137. <select id="selectUserRoles" resultType="java.lang.String">
  138. SELECT cr.role_name
  139. FROM company_user_role cur
  140. LEFT JOIN company_role cr ON cr.role_id = cur.role_id
  141. WHERE cur.user_id = #{userId}
  142. </select>
  143. <select id="selectCompanyUserList" parameterType="CompanyUser" resultMap="CompanyUserResult">
  144. select u.*, d.dept_name, d.leader from company_user u
  145. left join company_dept d on u.dept_id = d.dept_id
  146. where u.del_flag = '0'
  147. <if test="userName != null and userName != ''">
  148. AND u.user_name like concat( #{userName}, '%')
  149. </if>
  150. <if test="nickName != null and nickName != ''">
  151. AND u.nick_name like concat( #{nickName}, '%')
  152. </if>
  153. <if test="companyId != null and companyId != ''">
  154. AND u.company_id = #{companyId}
  155. </if>
  156. <if test="status != null and status != ''">
  157. AND u.status = #{status}
  158. </if>
  159. <if test="phonenumber != null and phonenumber != ''">
  160. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  161. </if>
  162. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  163. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  164. </if>
  165. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  166. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  167. </if>
  168. <if test="deptId != null and deptId != 0">
  169. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  170. </if>
  171. <if test="deptList != null and !deptList.isEmpty()">
  172. AND u.dept_id IN
  173. <foreach collection='deptList' item='item' open='(' separator=',' close=')'>
  174. #{item}
  175. </foreach>
  176. </if>
  177. <!-- 数据范围过滤 -->
  178. ${params.dataScope}
  179. </select>
  180. <select id="selectCompanyUserById" parameterType="Long" resultMap="CompanyUserResult">
  181. <include refid="selectUserVo"/>
  182. where u.user_id = #{userId}
  183. </select>
  184. <insert id="insertCompanyUser" parameterType="CompanyUser" useGeneratedKeys="true" keyProperty="userId">
  185. insert into company_user
  186. <trim prefix="(" suffix=")" suffixOverrides=",">
  187. <if test="companyId != null">company_id,</if>
  188. <if test="deptId != null">dept_id,</if>
  189. <if test="userName != null and userName != ''">user_name,</if>
  190. <if test="nickName != null and nickName != ''">nick_name,</if>
  191. <if test="userType != null">user_type,</if>
  192. <if test="email != null">email,</if>
  193. <if test="phonenumber != null">phonenumber,</if>
  194. <if test="sex != null">sex,</if>
  195. <if test="avatar != null">avatar,</if>
  196. <if test="idCard != null">id_card,</if>
  197. <if test="password != null">password,</if>
  198. <if test="status != null">status,</if>
  199. <if test="delFlag != null">del_flag,</if>
  200. <if test="loginIp != null">login_ip,</if>
  201. <if test="loginDate != null">login_date,</if>
  202. <if test="createBy != null">create_by,</if>
  203. <if test="createTime != null">create_time,</if>
  204. <if test="updateBy != null">update_by,</if>
  205. <if test="updateTime != null">update_time,</if>
  206. <if test="token != null">token,</if>
  207. <if test="remark != null">remark,</if>
  208. <if test="openId != null">open_id,</if>
  209. <if test="qrCodeWeixin != null">qr_code_weixin,</if>
  210. <if test="qrCodeWecom != null">qr_code_wecom,</if>
  211. <if test="jpushId != null">jpush_id,</if>
  212. <if test="qwUserId != null">qw_user_id,</if>
  213. <if test="qwStatus != null">qw_status,</if>
  214. <if test="voicePrintUrl != null">voice_print_url,</if>
  215. <if test="addressId != null">address_id,</if>
  216. <if test="domain != null">domain,</if>
  217. <if test="isAudit != null">`is_audit`,</if>
  218. </trim>
  219. <trim prefix="values (" suffix=")" suffixOverrides=",">
  220. <if test="companyId != null">#{companyId},</if>
  221. <if test="deptId != null">#{deptId},</if>
  222. <if test="userName != null and userName != ''">#{userName},</if>
  223. <if test="nickName != null and nickName != ''">#{nickName},</if>
  224. <if test="userType != null">#{userType},</if>
  225. <if test="email != null">#{email},</if>
  226. <if test="phonenumber != null">#{phonenumber},</if>
  227. <if test="sex != null">#{sex},</if>
  228. <if test="avatar != null">#{avatar},</if>
  229. <if test="idCard != null">#{idCard},</if>
  230. <if test="password != null">#{password},</if>
  231. <if test="status != null">#{status},</if>
  232. <if test="delFlag != null">#{delFlag},</if>
  233. <if test="loginIp != null">#{loginIp},</if>
  234. <if test="loginDate != null">#{loginDate},</if>
  235. <if test="createBy != null">#{createBy},</if>
  236. <if test="createTime != null">#{createTime},</if>
  237. <if test="updateBy != null">#{updateBy},</if>
  238. <if test="updateTime != null">#{updateTime},</if>
  239. <if test="token != null">#{token},</if>
  240. <if test="remark != null">#{remark},</if>
  241. <if test="openId != null">#{openId},</if>
  242. <if test="qrCodeWeixin != null">#{qrCodeWeixin},</if>
  243. <if test="qrCodeWecom != null">#{qrCodeWecom},</if>
  244. <if test="jpushId != null">#{jpushId},</if>
  245. <if test="qwUserId != null">#{qwUserId},</if>
  246. <if test="qwStatus != null">#{qwStatus},</if>
  247. <if test="voicePrintUrl != null">#{voicePrintUrl},</if>
  248. <if test="addressId != null">#{addressId},</if>
  249. <if test="domain != null">#{domain},</if>
  250. <if test="isAudit != null">#{isAudit},</if>
  251. </trim>
  252. </insert>
  253. <insert id="insertQwIpadTotal">
  254. insert into qw_ipad_total (company_id,company_name,bind_count,stat_time) values
  255. <foreach item="item" collection="list" separator=",">
  256. (#{item.companyId},#{item.companyName},#{item.bindCount},#{item.statTime})
  257. </foreach>
  258. </insert>
  259. <update id="uploadQrCode">
  260. update company_user set qr_code_weixin=#{url} where user_id=${userId}
  261. </update>
  262. <update id="updateCompanyUser" parameterType="CompanyUser">
  263. update company_user
  264. <trim prefix="SET" suffixOverrides=",">
  265. <if test="companyId != null">company_id = #{companyId},</if>
  266. <if test="deptId != null">dept_id = #{deptId},</if>
  267. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  268. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  269. <if test="userType != null">user_type = #{userType},</if>
  270. <if test="email != null">email = #{email},</if>
  271. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  272. <if test="sex != null">sex = #{sex},</if>
  273. <if test="avatar != null">avatar = #{avatar},</if>
  274. <if test="idCard != null">id_card = #{idCard},</if>
  275. <if test="password != null and password != '' ">password = #{password},</if>
  276. <if test="status != null">status = #{status},</if>
  277. <if test="delFlag != null">del_flag = #{delFlag},</if>
  278. <if test="loginIp != null">login_ip = #{loginIp},</if>
  279. <if test="loginDate != null">login_date = #{loginDate},</if>
  280. <if test="createBy != null">create_by = #{createBy},</if>
  281. <if test="createTime != null">create_time = #{createTime},</if>
  282. <if test="updateBy != null">update_by = #{updateBy},</if>
  283. <if test="updateTime != null">update_time = #{updateTime},</if>
  284. <if test="token != null">token = #{token},</if>
  285. <if test="remark != null">remark = #{remark},</if>
  286. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  287. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  288. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  289. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  290. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  291. <if test="voicePrintUrl != null">voice_print_url = #{voicePrintUrl},</if>
  292. <if test="addressId != null">address_id = #{addressId},</if>
  293. <if test="domain != null">domain = #{domain},</if>
  294. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  295. <if test="doctorId != null">`doctor_id` = #{doctorId},</if>
  296. </trim>
  297. where user_id = #{userId}
  298. </update>
  299. <update id="updateAllCompanyUser" parameterType="CompanyUser">
  300. update company_user
  301. <trim prefix="SET" suffixOverrides=",">
  302. <if test="companyId != null">company_id = #{companyId},</if>
  303. <if test="deptId != null">dept_id = #{deptId},</if>
  304. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  305. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  306. <if test="email != null">email = #{email},</if>
  307. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  308. <if test="sex != null">sex = #{sex},</if>
  309. <if test="avatar != null">avatar = #{avatar},</if>
  310. <if test="idCard != null">id_card = #{idCard},</if>
  311. <if test="password != null and password != '' ">password = #{password},</if>
  312. <if test="status != null">status = #{status},</if>
  313. <if test="delFlag != null">del_flag = #{delFlag},</if>
  314. <if test="loginIp != null">login_ip = #{loginIp},</if>
  315. <if test="loginDate != null">login_date = #{loginDate},</if>
  316. <if test="createBy != null">create_by = #{createBy},</if>
  317. <if test="createTime != null">create_time = #{createTime},</if>
  318. <if test="updateBy != null">update_by = #{updateBy},</if>
  319. <if test="updateTime != null">update_time = #{updateTime},</if>
  320. <if test="token != null">token = #{token},</if>
  321. <if test="remark != null">remark = #{remark},</if>
  322. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  323. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  324. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  325. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  326. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  327. <if test="domain != null">`domain` = #{domain},</if>
  328. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  329. <if test="addressId != null">`address_id` = #{addressId},</if>
  330. <if test="maOpenId != null">`ma_open_id` = #{maOpenId},</if>
  331. </trim>
  332. where company_id = #{companyId}
  333. </update>
  334. <delete id="deleteCompanyUserById" parameterType="Long">
  335. delete from company_user where user_id = #{userId}
  336. </delete>
  337. <delete id="deleteCompanyUserByIds" parameterType="String">
  338. delete from company_user where user_id in
  339. <foreach item="userId" collection="array" open="(" separator="," close=")">
  340. #{userId}
  341. </foreach>
  342. </delete>
  343. <update id="updateUserAvatar" parameterType="SysUser">
  344. update company_user set avatar = #{avatar} where user_name = #{userName}
  345. </update>
  346. <update id="resetUserPwd" parameterType="SysUser">
  347. update company_user set password = #{password} where user_name = #{userName}
  348. </update>
  349. <select id="selectUserByUserName" parameterType="String" resultMap="CompanyUserResult">
  350. <include refid="selectUserVo"/>
  351. where u.user_name = #{userName}
  352. </select>
  353. <select id="selectCompanyQwUserByIds" resultType="com.fs.company.vo.CompanyQwUserByIdsVo">
  354. SELECT b.user_id,b.company_id,a.qw_user_id,a.qw_user_name,b.nick_name
  355. FROM qw_user a inner join company_user b on a.company_user_id = b.user_id
  356. where a.id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>
  357. and b.voice_print_url is not null
  358. </select>
  359. <select id="selectCompanyUserByIds" resultType="com.fs.company.domain.CompanyUser">
  360. select cu.*
  361. from company_user cu
  362. where cu.user_id in
  363. <foreach collection="ids" item="id" open="(" separator="," close=")">
  364. #{id}
  365. </foreach>
  366. </select>
  367. <select id="selectAllCompanyUserAndSelf" resultType="CompanyUser">
  368. SELECT
  369. *
  370. FROM
  371. company_user
  372. <where>
  373. del_flag = 0
  374. <if test="companyId == null">
  375. AND (company_user.user_id = #{userId} or company_user.parent_id = #{userId})
  376. </if>
  377. <if test="companyId != null">
  378. AND company_user.company_id = #{companyId}
  379. </if>
  380. </where>
  381. </select>
  382. <select id="getAllUserListLimit" resultType="com.fs.company.domain.CompanyUser">
  383. SELECT * FROM company_user
  384. <where>
  385. <if test="companyId != null">
  386. AND company_id != #{companyId}
  387. </if>
  388. <if test="keywords != null and keywords != ''">
  389. AND (
  390. phonenumber LIKE CONCAT(#{keywords}, '%')
  391. OR user_name LIKE CONCAT(#{keywords}, '%')
  392. OR nick_name LIKE CONCAT(#{keywords}, '%')
  393. )
  394. </if>
  395. </where>
  396. limit 10
  397. </select>
  398. <select id="selectCompanyUserByPhone" resultType="com.fs.company.domain.CompanyUser">
  399. select user_id, dept_id, user_name, nick_name, user_type, email, phonenumber, sex, avatar, password, status, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, remark, open_id, id_card, company_id, qr_code_weixin, qr_code_wecom, jpush_id, qw_user_id, qw_status, voice_print_url, address_id, `domain`, parent_id, bind_code from company_user where phonenumber=#{phone} and del_flag=0
  400. </select>
  401. <sql id="selectUserVo">
  402. select u.user_id,u.company_id,u.qw_user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar,
  403. u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by,
  404. u.create_time,u.id_card, u.remark,u.user_type,u.open_id,u.qr_code_weixin,u.qr_code_wecom,u.jpush_id,u.domain,u.is_audit,u.address_id,
  405. d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
  406. r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
  407. u.is_need_register_member, u.is_allowed_all_register,u.doctor_id
  408. from company_user u
  409. left join company_dept d on u.dept_id = d.dept_id
  410. left join company_user_role ur on u.user_id = ur.user_id
  411. left join company_role r on r.role_id = ur.role_id
  412. </sql>
  413. <select id="selectAllCompanyUserByCompanyIdAndDeptId" resultType="com.fs.company.domain.CompanyUser">
  414. select * from company_user where del_flag = '0'
  415. and company_id = #{companyId}
  416. <if test="deptId != null">
  417. and dept_id = #{deptId}
  418. </if>
  419. </select>
  420. <select id="selectCompanyUserListByMap" resultType="com.fs.his.vo.OptionsVO">
  421. select
  422. concat(cu.nick_name,'(',cu.user_id,')') as dictLabel,
  423. cu.user_id as dictValue
  424. from company_user cu
  425. <where>
  426. <if test="params.nickName != null and params.nickName != ''">
  427. and cu.nick_name like concat( '%',#{params.nickName}, '%')
  428. </if>
  429. <if test="params.companyId != null">
  430. and cu.company_id = #{params.companyId}
  431. </if>
  432. <if test="params.combinedDeptList != null and !params.combinedDeptList.isEmpty() ">
  433. AND cu.dept_id IN
  434. <foreach collection='params.combinedDeptList' item='item' open='(' separator=',' close=')'>
  435. #{item}
  436. </foreach>
  437. </if>
  438. </where>
  439. </select>
  440. <update id="setIsRegisterMember" parameterType="Long">
  441. update company_user
  442. set is_need_register_member = #{status} where user_id in
  443. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  444. #{userId}
  445. </foreach>
  446. </update>
  447. <update id="auditUsers">
  448. update company_user
  449. set is_audit = 1
  450. where user_id in
  451. <foreach collection="userIds" open="(" close=")" separator="," item="id">
  452. #{id}
  453. </foreach>
  454. </update>
  455. <select id="selectMyUserList" parameterType="com.fs.company.vo.CompanyUserVO" resultMap="CompanyUserVOResult">
  456. select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.open_id,u.id_card, d.dept_name, d.leader, u.is_audit,
  457. cr.role_id, cr.role_name
  458. from company_user u
  459. left join company_user_role cur on cur.user_id = u.user_id
  460. left join company_role cr on cr.role_id = cur.role_id
  461. left join company_dept d on u.dept_id = d.dept_id
  462. where u.del_flag = '0' and u.status=0
  463. <if test="companyId != null ">
  464. AND u.company_id = #{companyId}
  465. </if>
  466. <if test="nickName != null and nickName != ''">
  467. AND u.nick_name like concat('%', #{nickName}, '%')
  468. </if>
  469. <if test="phonenumber != null and phonenumber != ''">
  470. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  471. </if>
  472. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  473. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  474. </if>
  475. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  476. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  477. </if>
  478. <if test="deptId != null and deptId != 0">
  479. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  480. </if>
  481. <if test="isAudit != null">
  482. AND u.is_audit = #{isAudit}
  483. </if>
  484. </select>
  485. <resultMap type="com.fs.company.vo.CompanyUserVO" id="CompanyUserVOResult">
  486. <result property="userId" column="user_id" />
  487. <result property="companyId" column="company_id" />
  488. <result property="deptId" column="dept_id" />
  489. <result property="userName" column="user_name" />
  490. <result property="nickName" column="nick_name" />
  491. <result property="userType" column="user_type" />
  492. <result property="email" column="email" />
  493. <result property="phonenumber" column="phonenumber" />
  494. <result property="sex" column="sex" />
  495. <result property="avatar" column="avatar" />
  496. <result property="idCard" column="id_card" />
  497. <result property="password" column="password" />
  498. <result property="status" column="status" />
  499. <result property="delFlag" column="del_flag" />
  500. <result property="loginIp" column="login_ip" />
  501. <result property="loginDate" column="login_date" />
  502. <result property="createBy" column="create_by" />
  503. <result property="createTime" column="create_time" />
  504. <result property="updateBy" column="update_by" />
  505. <result property="updateTime" column="update_time" />
  506. <result property="token" column="token" />
  507. <result property="remark" column="remark" />
  508. <result property="openId" column="open_id" />
  509. <result property="nowDayCustomerCount" column="now_day_customer_count" />
  510. <result property="domain" column="domain" />
  511. <result property="isAudit" column="is_audit" />
  512. <result property="addressId" column="address_id" />
  513. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  514. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  515. <collection property="posts" javaType="java.util.ArrayList" ofType="com.fs.company.domain.CompanyPost"
  516. select="com.fs.company.mapper.CompanyPostMapper.selectPostsByUserId" column="{user_id=user_id}" />
  517. </resultMap>
  518. <select id="getUserInfoByUserIds" resultType="com.fs.company.domain.CompanyUser">
  519. SELECT user_id,user_name FROM company_user WHERE user_id IN <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
  520. #{item}
  521. </foreach>
  522. </select>
  523. <select id="queryCompanyUserWatchCount" resultType="java.lang.Long">
  524. select count(1) from fs_course_watch_log
  525. <where>
  526. <if test="companyUserId != null">
  527. AND company_user_id = #{companyUserId}
  528. </if>
  529. <if test="previousDay != null">
  530. and camp_period_time = ${previousDay}
  531. </if>
  532. </where>
  533. </select>
  534. <select id="queryCompanyUserWatchCountCompleted" resultType="java.lang.Long">
  535. select count(1) from fs_course_watch_log
  536. <where>
  537. AND log_type = 2
  538. <if test="companyUserId != null">
  539. AND company_user_id = #{companyUserId}
  540. </if>
  541. <if test="previousDay != null">
  542. and camp_period_time = ${previousDay}
  543. </if>
  544. </where>
  545. </select>
  546. <select id="queryCompanyUserInterruptCount" resultType="java.lang.Long">
  547. select count(1) from fs_course_watch_log
  548. <where>
  549. AND log_type = 4
  550. <if test="companyUserId != null">
  551. AND company_user_id = #{companyUserId}
  552. </if>
  553. <if test="previousDay != null">
  554. and camp_period_time = ${previousDay}
  555. </if>
  556. </where>
  557. </select>
  558. <select id="getCompanyUserList" resultType="com.fs.company.domain.CompanyUser">
  559. SELECT
  560. u.user_id,
  561. u.user_name,
  562. u.phonenumber,
  563. cdbu.company_user_id
  564. FROM
  565. company_user u
  566. LEFT JOIN company_domain_bind_user cdbu ON u.user_id=cdbu.company_user_id
  567. WHERE
  568. u.del_flag = '0'
  569. AND cdbu.id IS NULL
  570. <if test="userName != null and userName != ''">
  571. AND u.user_name like concat( #{userName}, '%')
  572. </if>
  573. <if test="nickName != null and nickName != ''">
  574. AND u.nick_name like concat( #{nickName}, '%')
  575. </if>
  576. <if test="companyId != null and companyId != ''">
  577. AND u.company_id = #{companyId}
  578. </if>
  579. <if test="status != null and status != ''">
  580. AND u.status = #{status}
  581. </if>
  582. <if test="phonenumber != null and phonenumber != ''">
  583. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  584. </if>
  585. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  586. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  587. </if>
  588. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  589. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  590. </if>
  591. <!-- 数据范围过滤 -->
  592. ${params.dataScope}
  593. </select>
  594. <select id="selectQwUserListLikeName" resultType="com.fs.qw.vo.QwOptionsVO">
  595. select
  596. concat(qw.qw_user_name,'(',qw.id,')') as dictLabel,
  597. qw.id as dictValue
  598. from qw_user qw
  599. <where>
  600. <if test="params.qwUserName != null and params.qwUserName != ''">
  601. and qw.qw_user_name like concat(#{params.qwUserName}, '%')
  602. </if>
  603. <if test="params.companyId != null">
  604. and qw.company_id = #{params.companyId}
  605. </if>
  606. </where>
  607. </select>
  608. <select id="selectCompanyUserNameByIds" resultType="java.lang.String">
  609. select GROUP_CONCAT(DISTINCT nick_name ORDER BY nick_name SEPARATOR ',') as nick_name from company_user where user_id in
  610. <foreach collection="companyUserIds.split(',')" item="companyUserId" open="(" close=")" separator=",">
  611. #{companyUserId}
  612. </foreach>
  613. </select>
  614. <update id="batchUpdateUserDomain">
  615. update company_user set domain=#{domain} where user_id in <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">#{item}</foreach>
  616. </update>
  617. <update id="batchUpdateUserDept">
  618. UPDATE company_user
  619. SET dept_id = CASE user_id
  620. <foreach collection="companyUserList" item="item" separator=" ">
  621. WHEN #{item.userId} THEN #{item.deptId}
  622. </foreach>
  623. END
  624. WHERE user_id IN
  625. <foreach collection="companyUserList" item="item" open="(" separator="," close=")">
  626. #{item.userId}
  627. </foreach>
  628. </update>
  629. <select id="selectCompanyUserByCompanyUserId" resultMap="CompanyUserResult">
  630. select * from company_user where user_id = #{companyUserId}
  631. </select>
  632. <select id="selectCompanyByIpadStatus" resultType="com.fs.company.vo.QwIpadTotalVo">
  633. select company_id companyId,company_name companyName,
  634. sum(bind_count) bindCount,stat_time statTime from qw_ipad_total
  635. <where>
  636. <if test="dateTime != null">
  637. and stat_time like concat(#{dateTime}, '%')
  638. </if>
  639. </where>
  640. group by company_id,company_name
  641. </select>
  642. <select id="selectCompanyByIpadStatusCount" resultType="com.fs.company.vo.QwIpadTotalVo">
  643. SELECT qw.company_id companyId,c.company_name companyName,count(1) bindCount
  644. FROM `qw_user` qw left join company c on qw.company_id = c.company_id
  645. where qw.ipad_status is not null
  646. GROUP BY qw.company_id
  647. </select>
  648. <update id="updateAllowedAllRegister" parameterType="Long">
  649. update company_user
  650. set is_allowed_all_register = #{status} where user_id in
  651. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  652. #{userId}
  653. </foreach>
  654. </update>
  655. <select id="selectCompanyUserNameByIdsList" resultType="java.lang.String">
  656. SELECT nick_name from company_user where user_id in
  657. <foreach collection="companyUserIDs" item="id" open="(" separator="," close=")">
  658. #{id}
  659. </foreach>
  660. </select>
  661. <!-- 批量更新公司用户的绑定销售ID -->
  662. <update id="batchUpdateBindCompanyUserId">
  663. update fs_user
  664. set bind_company_user_id = #{bindCompanyUserId}
  665. where user_id in
  666. <foreach collection="userIds" item="userId" open="(" separator="," close=")">
  667. #{userId}
  668. </foreach>
  669. </update>
  670. <!-- 根据销售ID查询绑定的fs_user用户列表 -->
  671. <select id="selectBoundFsUsersByCompanyUserId" resultType="com.fs.hisStore.domain.FsUserScrm">
  672. SELECT *
  673. FROM fs_user
  674. WHERE bind_company_user_id = #{companyUserId}
  675. AND is_del = 0
  676. </select>
  677. </mapper>