CompanyUserMapper.xml 35 KB

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