CompanyUserMapper.xml 34 KB

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