CompanyUserMapper.xml 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  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="expirationTime" column="expiration_time" />
  28. <result property="token" column="token" />
  29. <result property="remark" column="remark" />
  30. <result property="openId" column="open_id" />
  31. <result property="qrCodeWeixin" column="qr_code_weixin" />
  32. <result property="qrCodeWecom" column="qr_code_wecom" />
  33. <result property="jpushId" column="jpush_id" />
  34. <result property="firstchar" column="firstchar" />
  35. <result property="postName" column="post_name" />
  36. <result property="deptName" column="dept_name" />
  37. <result property="qwUserId" column="qw_user_id" />
  38. <result property="qwStatus" column="qw_status" />
  39. <result property="voicePrintUrl" column="voice_print_url" />
  40. <result property="addressId" column="address_id" />
  41. <result property="domain" column="domain" />
  42. <result property="isAudit" column="is_audit" />
  43. <result property="isNeedRegisterMember" column="is_need_register_member" />
  44. <result property="isAllowedAllRegister" column="is_allowed_all_register" />
  45. <result property="doctorId" column="doctor_id" />
  46. <result property="bindCompanyUserId" column="bind_company_user_id" />
  47. <result property="unionId" column="union_id" />
  48. <result property="cidServerId" column="cid_server_id"/>
  49. <result property="isCustomerVoice" column="is_customer_voice"/>
  50. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  51. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  52. </resultMap>
  53. <resultMap id="CompanyUserQwListVOResult" type="com.fs.company.vo.CompanyUserQwListVO">
  54. <id property="userId" column="user_id"/>
  55. <result property="userName" column="user_name"/>
  56. <result property="nickName" column="nick_name"/>
  57. <result property="companyId" column="company_id"/>
  58. <result property="status" column="status"/>
  59. <result property="qwStatus" column="qw_status"/>
  60. <result property="qwUserId" column="qw_user_id"/>
  61. <result property="phonenumber" column="phonenumber"/>
  62. <result property="createTime" column="create_time"/>
  63. <result property="deptId" column="dept_id"/>
  64. <result property="deptName" column="dept_name"/>
  65. <result property="qrCodeWeixin" column="qr_code_weixin"/>
  66. <result property="postName" column="post_name"/>
  67. <result property="qrCodeWecom" column="qr_code_wecom"/>
  68. <result property="jpushId" column="jpush_id"/>
  69. <result property="callerNo" column="caller_no"/>
  70. <result property="isNeedRegisterMember" column="is_need_register_member" />
  71. <result property="isAllowedAllRegister" column="is_allowed_all_register" />
  72. <result property="cidServerId" column="cid_server_id"/>
  73. <result property="aiSipCallUserId" column="ai_sip_call_user_id"/>
  74. <collection property="roleNames" ofType="java.lang.String" javaType="java.util.ArrayList"
  75. select="selectUserRoles" column="user_id"/>
  76. </resultMap>
  77. <resultMap id="deptResult" type="CompanyDept">
  78. <id property="deptId" column="dept_id"/>
  79. <result property="parentId" column="parent_id"/>
  80. <result property="deptName" column="dept_name"/>
  81. <result property="orderNum" column="order_num"/>
  82. <result property="leader" column="leader"/>
  83. <result property="status" column="dept_status"/>
  84. </resultMap>
  85. <resultMap id="RoleResult" type="CompanyRole">
  86. <id property="roleId" column="role_id" />
  87. <result property="roleName" column="role_name" />
  88. <result property="roleKey" column="role_key" />
  89. <result property="roleSort" column="role_sort" />
  90. <result property="dataScope" column="data_scope" />
  91. <result property="status" column="role_status" />
  92. </resultMap>
  93. <select id="selectCompanyUserQwListVO" resultMap="CompanyUserQwListVOResult">
  94. select
  95. u.user_id, u.user_name, u.nick_name, u.company_id, u.status,
  96. u.qw_status, u.phonenumber, u.create_time, u.dept_id,
  97. u.qr_code_weixin, u.user_type, u.qr_code_wecom, u.jpush_id,
  98. u.is_need_register_member,u.is_allowed_all_register,
  99. u.avatar,u.address_id,
  100. u.qw_user_id,
  101. u.is_customer_voice,
  102. u.doctor_id,
  103. d.dept_name,
  104. d.leader,
  105. GROUP_CONCAT(fu.nick_name) bindUser,
  106. cfu.`status` bindStatus,
  107. u.cid_server_id,
  108. u.ai_sip_call_user_id,
  109. u.expiration_time,
  110. xub.account_id
  111. from
  112. company_user u
  113. left join
  114. company_dept d on u.dept_id = d.dept_id
  115. LEFT JOIN
  116. company_fs_user cfu on u.user_id=cfu.company_user_id
  117. LEFT JOIN fs_user fu on cfu.fs_user_id=fu.user_id
  118. LEFT JOIN xsy_user_bind xub on xub.company_user_id=u.user_id
  119. where
  120. u.del_flag = '0'
  121. <if test="userId != null ">
  122. AND u.user_id = #{userId}
  123. </if>
  124. <if test="userName != null and userName != ''">
  125. AND u.user_name like concat('%', #{userName}, '%')
  126. </if>
  127. <if test="nickName != null and nickName != ''">
  128. AND u.nick_name like concat('%', #{nickName}, '%')
  129. </if>
  130. <if test="companyId != null and companyId != ''">
  131. AND u.company_id = #{companyId}
  132. </if>
  133. <if test="status != null and status != ''">
  134. AND u.status = #{status}
  135. </if>
  136. <if test="qwStatus != null">
  137. AND u.qw_status = #{qwStatus}
  138. </if>
  139. <if test="phonenumber != null and phonenumber != ''">
  140. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  141. </if>
  142. <if test="beginTime != null and beginTime != ''">
  143. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  144. </if>
  145. <if test="endTime != null and endTime != ''">
  146. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  147. </if>
  148. <if test="deptId != null and deptId != 0">
  149. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  150. </if>
  151. <!-- 数据范围过滤 -->
  152. ${params.dataScope}
  153. GROUP BY u.user_id
  154. </select>
  155. <!-- <select id="selectCompanyUserQwListVO" resultMap="CompanyUserQwListVOResult">-->
  156. <!-- select-->
  157. <!-- u.user_id, u.user_name, u.nick_name, u.company_id, u.status,-->
  158. <!-- u.qw_status, u.phonenumber, u.create_time, u.dept_id,-->
  159. <!-- u.qr_code_weixin, u.user_type, u.qr_code_wecom, u.jpush_id,-->
  160. <!-- u.is_need_register_member,u.is_allowed_all_register,-->
  161. <!-- u.avatar,u.address_id,-->
  162. <!-- u.qw_user_id,-->
  163. <!-- u.doctor_id,-->
  164. <!-- u.cid_server_id,-->
  165. <!-- d.dept_name,-->
  166. <!-- d.leader,-->
  167. <!-- u.ai_sip_call_user_id-->
  168. <!-- from-->
  169. <!-- company_user u-->
  170. <!-- left join-->
  171. <!-- company_dept d on u.dept_id = d.dept_id-->
  172. <!-- where-->
  173. <!-- u.del_flag = '0'-->
  174. <!-- <if test="userId != null ">-->
  175. <!-- AND u.user_id = #{userId}-->
  176. <!-- </if>-->
  177. <!-- <if test="userName != null and userName != ''">-->
  178. <!-- AND u.user_name like concat('%', #{userName}, '%')-->
  179. <!-- </if>-->
  180. <!-- <if test="nickName != null and nickName != ''">-->
  181. <!-- AND u.nick_name like concat( #{nickName}, '%')-->
  182. <!-- </if>-->
  183. <!-- <if test="companyId != null and companyId != ''">-->
  184. <!-- AND u.company_id = #{companyId}-->
  185. <!-- </if>-->
  186. <!-- <if test="status != null and status != ''">-->
  187. <!-- AND u.status = #{status}-->
  188. <!-- </if>-->
  189. <!-- <if test="qwStatus != null">-->
  190. <!-- AND u.qw_status = #{qwStatus}-->
  191. <!-- </if>-->
  192. <!-- <if test="phonenumber != null and phonenumber != ''">-->
  193. <!-- AND u.phonenumber like concat('%', #{phonenumber}, '%')-->
  194. <!-- </if>-->
  195. <!-- <if test="beginTime != null and beginTime != ''">-->
  196. <!-- AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')-->
  197. <!-- </if>-->
  198. <!-- <if test="endTime != null and endTime != ''">-->
  199. <!-- AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')-->
  200. <!-- </if>-->
  201. <!-- <if test="deptId != null and deptId != 0">-->
  202. <!-- AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))-->
  203. <!-- </if>-->
  204. <!-- &lt;!&ndash; 数据范围过滤 &ndash;&gt;-->
  205. <!-- ${params.dataScope}-->
  206. <!-- </select>-->
  207. <!-- 角色子查询 -->
  208. <select id="selectUserRoles" resultType="java.lang.String">
  209. SELECT cr.role_name
  210. FROM company_user_role cur
  211. LEFT JOIN company_role cr ON cr.role_id = cur.role_id
  212. WHERE cur.user_id = #{userId}
  213. </select>
  214. <select id="selectCompanyUserList" parameterType="CompanyUser" resultMap="CompanyUserResult">
  215. select u.*, d.dept_name, d.leader from company_user u
  216. left join company_dept d on u.dept_id = d.dept_id
  217. where u.del_flag = '0'
  218. <if test="userName != null and userName != ''">
  219. AND u.user_name like concat( #{userName}, '%')
  220. </if>
  221. <if test="nickName != null and nickName != ''">
  222. AND u.nick_name like concat( #{nickName}, '%')
  223. </if>
  224. <if test="companyId != null and companyId != ''">
  225. AND u.company_id = #{companyId}
  226. </if>
  227. <if test="status != null and status != ''">
  228. AND u.status = #{status}
  229. </if>
  230. <if test="phonenumber != null and phonenumber != ''">
  231. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  232. </if>
  233. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  234. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  235. </if>
  236. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  237. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  238. </if>
  239. <if test="deptId != null and deptId != 0">
  240. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  241. </if>
  242. <if test="deptList != null and !deptList.isEmpty()">
  243. AND u.dept_id IN
  244. <foreach collection='deptList' item='item' open='(' separator=',' close=')'>
  245. #{item}
  246. </foreach>
  247. </if>
  248. <!-- 数据范围过滤 -->
  249. ${params.dataScope}
  250. </select>
  251. <select id="selectCompanyUserById" parameterType="Long" resultMap="CompanyUserResult">
  252. <include refid="selectUserVo"/>
  253. where u.user_id = #{userId}
  254. </select>
  255. <insert id="insertCompanyUser" parameterType="CompanyUser" useGeneratedKeys="true" keyProperty="userId">
  256. insert into company_user
  257. <trim prefix="(" suffix=")" suffixOverrides=",">
  258. <if test="companyId != null">company_id,</if>
  259. <if test="deptId != null">dept_id,</if>
  260. <if test="userName != null and userName != ''">user_name,</if>
  261. <if test="nickName != null and nickName != ''">nick_name,</if>
  262. <if test="userType != null">user_type,</if>
  263. <if test="email != null">email,</if>
  264. <if test="phonenumber != null">phonenumber,</if>
  265. <if test="sex != null">sex,</if>
  266. <if test="avatar != null">avatar,</if>
  267. <if test="idCard != null">id_card,</if>
  268. <if test="password != null">password,</if>
  269. <if test="status != null">status,</if>
  270. <if test="delFlag != null">del_flag,</if>
  271. <if test="loginIp != null">login_ip,</if>
  272. <if test="loginDate != null">login_date,</if>
  273. <if test="createBy != null">create_by,</if>
  274. <if test="createTime != null">create_time,</if>
  275. <if test="updateBy != null">update_by,</if>
  276. <if test="updateTime != null">update_time,</if>
  277. <if test="expirationTime != null">expiration_time,</if>
  278. <if test="token != null">token,</if>
  279. <if test="remark != null">remark,</if>
  280. <if test="openId != null">open_id,</if>
  281. <if test="qrCodeWeixin != null">qr_code_weixin,</if>
  282. <if test="qrCodeWecom != null">qr_code_wecom,</if>
  283. <if test="jpushId != null">jpush_id,</if>
  284. <if test="qwUserId != null">qw_user_id,</if>
  285. <if test="qwStatus != null">qw_status,</if>
  286. <if test="voicePrintUrl != null">voice_print_url,</if>
  287. <if test="addressId != null">address_id,</if>
  288. <if test="domain != null">domain,</if>
  289. <if test="isAudit != null">`is_audit`,</if>
  290. <if test="isCustomerVoice != null">`is_customer_voice`,</if>
  291. </trim>
  292. <trim prefix="values (" suffix=")" suffixOverrides=",">
  293. <if test="companyId != null">#{companyId},</if>
  294. <if test="deptId != null">#{deptId},</if>
  295. <if test="userName != null and userName != ''">#{userName},</if>
  296. <if test="nickName != null and nickName != ''">#{nickName},</if>
  297. <if test="userType != null">#{userType},</if>
  298. <if test="email != null">#{email},</if>
  299. <if test="phonenumber != null">#{phonenumber},</if>
  300. <if test="sex != null">#{sex},</if>
  301. <if test="avatar != null">#{avatar},</if>
  302. <if test="idCard != null">#{idCard},</if>
  303. <if test="password != null">#{password},</if>
  304. <if test="status != null">#{status},</if>
  305. <if test="delFlag != null">#{delFlag},</if>
  306. <if test="loginIp != null">#{loginIp},</if>
  307. <if test="loginDate != null">#{loginDate},</if>
  308. <if test="createBy != null">#{createBy},</if>
  309. <if test="createTime != null">#{createTime},</if>
  310. <if test="updateBy != null">#{updateBy},</if>
  311. <if test="updateTime != null">#{updateTime},</if>
  312. <if test="expirationTime != null">#{expirationTime},</if>
  313. <if test="token != null">#{token},</if>
  314. <if test="remark != null">#{remark},</if>
  315. <if test="openId != null">#{openId},</if>
  316. <if test="qrCodeWeixin != null">#{qrCodeWeixin},</if>
  317. <if test="qrCodeWecom != null">#{qrCodeWecom},</if>
  318. <if test="jpushId != null">#{jpushId},</if>
  319. <if test="qwUserId != null">#{qwUserId},</if>
  320. <if test="qwStatus != null">#{qwStatus},</if>
  321. <if test="voicePrintUrl != null">#{voicePrintUrl},</if>
  322. <if test="addressId != null">#{addressId},</if>
  323. <if test="domain != null">#{domain},</if>
  324. <if test="isAudit != null">#{isAudit},</if>
  325. <if test="isCustomerVoice != null">#{isCustomerVoice},</if>
  326. </trim>
  327. </insert>
  328. <insert id="insertQwIpadTotal">
  329. insert into qw_ipad_total (company_id,company_name,bind_count,stat_time) values
  330. <foreach item="item" collection="list" separator=",">
  331. (#{item.companyId},#{item.companyName},#{item.bindCount},#{item.statTime})
  332. </foreach>
  333. </insert>
  334. <update id="uploadQrCode">
  335. update company_user set qr_code_weixin=#{url} where user_id=${userId}
  336. </update>
  337. <update id="updateCompanyUser" parameterType="CompanyUser">
  338. update company_user
  339. <trim prefix="SET" suffixOverrides=",">
  340. <if test="companyId != null">company_id = #{companyId},</if>
  341. <if test="deptId != null">dept_id = #{deptId},</if>
  342. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  343. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  344. <if test="userType != null">user_type = #{userType},</if>
  345. <if test="email != null">email = #{email},</if>
  346. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  347. <if test="sex != null">sex = #{sex},</if>
  348. <if test="avatar != null">avatar = #{avatar},</if>
  349. <if test="idCard != null">id_card = #{idCard},</if>
  350. <if test="password != null and password != '' ">password = #{password},</if>
  351. <if test="status != null">status = #{status},</if>
  352. <if test="delFlag != null">del_flag = #{delFlag},</if>
  353. <if test="loginIp != null">login_ip = #{loginIp},</if>
  354. <if test="loginDate != null">login_date = #{loginDate},</if>
  355. <if test="createBy != null">create_by = #{createBy},</if>
  356. <if test="createTime != null">create_time = #{createTime},</if>
  357. <if test="updateBy != null">update_by = #{updateBy},</if>
  358. <if test="updateTime != null">update_time = #{updateTime},</if>
  359. <if test="token != null">token = #{token},</if>
  360. <if test="remark != null">remark = #{remark},</if>
  361. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  362. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  363. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  364. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  365. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  366. <if test="voicePrintUrl != null">voice_print_url = #{voicePrintUrl},</if>
  367. <if test="addressId != null">address_id = #{addressId},</if>
  368. <if test="domain != null">domain = #{domain},</if>
  369. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  370. <if test="doctorId != null">`doctor_id` = #{doctorId},</if>
  371. <if test="unionId != null">`union_id` = #{unionId},</if>
  372. <if test="cidServerId != null">`cid_server_id` = #{cidServerId},</if>
  373. <if test="isCustomerVoice != null">`is_customer_voice` = #{isCustomerVoice},</if>
  374. </trim>
  375. where user_id = #{userId}
  376. </update>
  377. <update id="updateAllCompanyUser" parameterType="CompanyUser">
  378. update company_user
  379. <trim prefix="SET" suffixOverrides=",">
  380. <if test="companyId != null">company_id = #{companyId},</if>
  381. <if test="deptId != null">dept_id = #{deptId},</if>
  382. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  383. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  384. <if test="email != null">email = #{email},</if>
  385. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  386. <if test="sex != null">sex = #{sex},</if>
  387. <if test="avatar != null">avatar = #{avatar},</if>
  388. <if test="idCard != null">id_card = #{idCard},</if>
  389. <if test="password != null and password != '' ">password = #{password},</if>
  390. <if test="status != null">status = #{status},</if>
  391. <if test="delFlag != null">del_flag = #{delFlag},</if>
  392. <if test="loginIp != null">login_ip = #{loginIp},</if>
  393. <if test="loginDate != null">login_date = #{loginDate},</if>
  394. <if test="createBy != null">create_by = #{createBy},</if>
  395. <if test="createTime != null">create_time = #{createTime},</if>
  396. <if test="updateBy != null">update_by = #{updateBy},</if>
  397. <if test="updateTime != null">update_time = #{updateTime},</if>
  398. <if test="token != null">token = #{token},</if>
  399. <if test="remark != null">remark = #{remark},</if>
  400. <if test="qrCodeWeixin != null">qr_code_weixin = #{qrCodeWeixin},</if>
  401. <if test="qrCodeWecom != null">qr_code_wecom = #{qrCodeWecom},</if>
  402. <if test="jpushId != null">jpush_id = #{jpushId},</if>
  403. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  404. <if test="qwStatus != null">qw_status = #{qwStatus},</if>
  405. <if test="domain != null">`domain` = #{domain},</if>
  406. <if test="isAudit != null">`is_audit` = #{isAudit},</if>
  407. <if test="addressId != null">`address_id` = #{addressId},</if>
  408. <if test="maOpenId != null">`ma_open_id` = #{maOpenId},</if>
  409. </trim>
  410. where company_id = #{companyId}
  411. </update>
  412. <delete id="deleteCompanyUserById" parameterType="Long">
  413. delete from company_user where user_id = #{userId}
  414. </delete>
  415. <delete id="deleteCompanyUserByIds" parameterType="String">
  416. delete from company_user where user_id in
  417. <foreach item="userId" collection="array" open="(" separator="," close=")">
  418. #{userId}
  419. </foreach>
  420. </delete>
  421. <update id="updateUserAvatar" parameterType="SysUser">
  422. update company_user set avatar = #{avatar} where user_name = #{userName}
  423. </update>
  424. <update id="resetUserPwd" parameterType="SysUser">
  425. update company_user set password = #{password} where user_name = #{userName}
  426. </update>
  427. <select id="selectUserByUserName" parameterType="String" resultMap="CompanyUserResult">
  428. <include refid="selectUserVo"/>
  429. where user_name = #{userName}
  430. </select>
  431. <select id="selectCompanyQwUserByIds" resultType="com.fs.company.vo.CompanyQwUserByIdsVo">
  432. SELECT b.user_id,b.company_id,a.qw_user_id,a.qw_user_name,b.nick_name
  433. FROM qw_user a inner join company_user b on a.company_user_id = b.user_id
  434. where a.id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>
  435. and b.voice_print_url is not null
  436. </select>
  437. <select id="selectCompanyUserByIds" resultType="com.fs.company.domain.CompanyUser">
  438. select cu.*
  439. from company_user cu
  440. where cu.user_id in
  441. <foreach collection="ids" item="id" open="(" separator="," close=")">
  442. #{id}
  443. </foreach>
  444. </select>
  445. <select id="selectAllCompanyUserAndSelf" resultType="CompanyUser">
  446. SELECT
  447. *
  448. FROM
  449. company_user
  450. <where>
  451. del_flag = 0
  452. <if test="companyId == null">
  453. AND (company_user.user_id = #{userId} or company_user.parent_id = #{userId})
  454. </if>
  455. <if test="companyId != null">
  456. AND company_user.company_id = #{companyId}
  457. </if>
  458. </where>
  459. </select>
  460. <select id="getAllUserListLimit" resultType="com.fs.company.domain.CompanyUser">
  461. SELECT * FROM company_user
  462. <where>
  463. <if test="companyId != null">
  464. AND company_id != #{companyId}
  465. </if>
  466. <if test="keywords != null and keywords != ''">
  467. AND (
  468. phonenumber LIKE CONCAT(#{keywords}, '%')
  469. OR user_name LIKE CONCAT(#{keywords}, '%')
  470. OR nick_name LIKE CONCAT(#{keywords}, '%')
  471. )
  472. </if>
  473. </where>
  474. limit 10
  475. </select>
  476. <select id="selectCompanyUserByPhone" resultType="com.fs.company.domain.CompanyUser">
  477. 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
  478. </select>
  479. <sql id="selectUserVo">
  480. select u.user_id,u.company_id,u.qw_user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar,
  481. u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by,
  482. 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,
  483. d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
  484. r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
  485. u.is_need_register_member, u.is_allowed_all_register,u.doctor_id,u.union_id,u.cid_server_id,u.is_customer_voice
  486. from company_user u
  487. left join company_dept d on u.dept_id = d.dept_id
  488. left join company_user_role ur on u.user_id = ur.user_id
  489. left join company_role r on r.role_id = ur.role_id
  490. </sql>
  491. <select id="selectAllCompanyUserByCompanyIdAndDeptId" resultType="com.fs.company.domain.CompanyUser">
  492. select * from company_user where del_flag = '0'
  493. and company_id = #{companyId}
  494. <if test="deptId != null">
  495. and dept_id = #{deptId}
  496. </if>
  497. </select>
  498. <select id="selectCompanyUserListByMap" resultType="com.fs.his.vo.OptionsVO">
  499. select
  500. concat(cu.nick_name,'(',cu.user_id,')') as dictLabel,
  501. cu.user_id as dictValue
  502. from company_user cu
  503. <where>
  504. <if test="params.nickName != null and params.nickName != ''">
  505. and cu.nick_name like concat( '%',#{params.nickName}, '%')
  506. </if>
  507. <if test="params.companyId != null">
  508. and cu.company_id = #{params.companyId}
  509. </if>
  510. <if test="params.combinedDeptList != null and !params.combinedDeptList.isEmpty() ">
  511. AND cu.dept_id IN
  512. <foreach collection='params.combinedDeptList' item='item' open='(' separator=',' close=')'>
  513. #{item}
  514. </foreach>
  515. </if>
  516. </where>
  517. </select>
  518. <update id="setIsRegisterMember" parameterType="Long">
  519. update company_user
  520. set is_need_register_member = #{status} where user_id in
  521. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  522. #{userId}
  523. </foreach>
  524. </update>
  525. <update id="auditUsers">
  526. update company_user
  527. set is_audit = 1
  528. where user_id in
  529. <foreach collection="userIds" open="(" close=")" separator="," item="id">
  530. #{id}
  531. </foreach>
  532. </update>
  533. <select id="selectMyUserList" parameterType="com.fs.company.vo.CompanyUserVO" resultMap="CompanyUserVOResult">
  534. 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,
  535. cr.role_id, cr.role_name
  536. from company_user u
  537. left join company_user_role cur on cur.user_id = u.user_id
  538. left join company_role cr on cr.role_id = cur.role_id
  539. left join company_dept d on u.dept_id = d.dept_id
  540. where u.del_flag = '0' and u.status=0
  541. <if test="companyId != null ">
  542. AND u.company_id = #{companyId}
  543. </if>
  544. <if test="nickName != null and nickName != ''">
  545. AND u.nick_name like concat('%', #{nickName}, '%')
  546. </if>
  547. <if test="phonenumber != null and phonenumber != ''">
  548. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  549. </if>
  550. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  551. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  552. </if>
  553. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  554. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  555. </if>
  556. <if test="deptId != null and deptId != 0">
  557. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  558. </if>
  559. <if test="isAudit != null">
  560. AND u.is_audit = #{isAudit}
  561. </if>
  562. </select>
  563. <resultMap type="com.fs.company.vo.CompanyUserVO" id="CompanyUserVOResult">
  564. <result property="userId" column="user_id" />
  565. <result property="companyId" column="company_id" />
  566. <result property="deptId" column="dept_id" />
  567. <result property="userName" column="user_name" />
  568. <result property="nickName" column="nick_name" />
  569. <result property="userType" column="user_type" />
  570. <result property="email" column="email" />
  571. <result property="phonenumber" column="phonenumber" />
  572. <result property="sex" column="sex" />
  573. <result property="avatar" column="avatar" />
  574. <result property="idCard" column="id_card" />
  575. <result property="password" column="password" />
  576. <result property="status" column="status" />
  577. <result property="delFlag" column="del_flag" />
  578. <result property="loginIp" column="login_ip" />
  579. <result property="loginDate" column="login_date" />
  580. <result property="createBy" column="create_by" />
  581. <result property="createTime" column="create_time" />
  582. <result property="updateBy" column="update_by" />
  583. <result property="updateTime" column="update_time" />
  584. <result property="token" column="token" />
  585. <result property="remark" column="remark" />
  586. <result property="openId" column="open_id" />
  587. <result property="nowDayCustomerCount" column="now_day_customer_count" />
  588. <result property="domain" column="domain" />
  589. <result property="isAudit" column="is_audit" />
  590. <result property="addressId" column="address_id" />
  591. <association property="dept" column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
  592. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  593. <collection property="posts" javaType="java.util.ArrayList" ofType="com.fs.company.domain.CompanyPost"
  594. select="com.fs.company.mapper.CompanyPostMapper.selectPostsByUserId" column="{user_id=user_id}" />
  595. </resultMap>
  596. <select id="getUserInfoByUserIds" resultType="com.fs.company.domain.CompanyUser">
  597. SELECT user_id,user_name FROM company_user WHERE user_id IN <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
  598. #{item}
  599. </foreach>
  600. </select>
  601. <select id="queryCompanyUserWatchCount" resultType="java.lang.Long">
  602. select count(1) from fs_course_watch_log
  603. <where>
  604. <if test="companyUserId != null">
  605. AND company_user_id = #{companyUserId}
  606. </if>
  607. <if test="previousDay != null">
  608. and camp_period_time = ${previousDay}
  609. </if>
  610. </where>
  611. </select>
  612. <select id="queryCompanyUserWatchCountCompleted" resultType="java.lang.Long">
  613. select count(1) from fs_course_watch_log
  614. <where>
  615. AND log_type = 2
  616. <if test="companyUserId != null">
  617. AND company_user_id = #{companyUserId}
  618. </if>
  619. <if test="previousDay != null">
  620. and camp_period_time = ${previousDay}
  621. </if>
  622. </where>
  623. </select>
  624. <select id="queryCompanyUserInterruptCount" resultType="java.lang.Long">
  625. select count(1) from fs_course_watch_log
  626. <where>
  627. AND log_type = 4
  628. <if test="companyUserId != null">
  629. AND company_user_id = #{companyUserId}
  630. </if>
  631. <if test="previousDay != null">
  632. and camp_period_time = ${previousDay}
  633. </if>
  634. </where>
  635. </select>
  636. <select id="getCompanyUserList" resultType="com.fs.company.domain.CompanyUser">
  637. SELECT
  638. u.user_id,
  639. u.user_name,
  640. u.phonenumber,
  641. cdbu.company_user_id
  642. FROM
  643. company_user u
  644. LEFT JOIN company_domain_bind_user cdbu ON u.user_id=cdbu.company_user_id
  645. WHERE
  646. u.del_flag = '0'
  647. AND cdbu.id IS NULL
  648. <if test="userName != null and userName != ''">
  649. AND u.user_name like concat( #{userName}, '%')
  650. </if>
  651. <if test="nickName != null and nickName != ''">
  652. AND u.nick_name like concat( #{nickName}, '%')
  653. </if>
  654. <if test="companyId != null and companyId != ''">
  655. AND u.company_id = #{companyId}
  656. </if>
  657. <if test="status != null and status != ''">
  658. AND u.status = #{status}
  659. </if>
  660. <if test="phonenumber != null and phonenumber != ''">
  661. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  662. </if>
  663. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  664. AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  665. </if>
  666. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  667. AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  668. </if>
  669. <!-- 数据范围过滤 -->
  670. ${params.dataScope}
  671. </select>
  672. <select id="selectQwUserListLikeName" resultType="com.fs.qw.vo.QwOptionsVO">
  673. select
  674. qw.qw_user_name as dictLabel,
  675. qw.id as dictValue
  676. from qw_user qw
  677. <where>
  678. <if test="params.qwUserName != null and params.qwUserName != ''">
  679. and qw.qw_user_name like concat(#{params.qwUserName}, '%')
  680. </if>
  681. <if test="params.companyId != null">
  682. and qw.company_id = #{params.companyId}
  683. </if>
  684. </where>
  685. </select>
  686. <select id="selectCompanyUserNameByIds" resultType="java.lang.String">
  687. select GROUP_CONCAT(DISTINCT nick_name ORDER BY nick_name SEPARATOR ',') as nick_name from company_user where user_id in
  688. <foreach collection="companyUserIds.split(',')" item="companyUserId" open="(" close=")" separator=",">
  689. #{companyUserId}
  690. </foreach>
  691. </select>
  692. <update id="batchUpdateUserDomain">
  693. update company_user set domain=#{domain} where user_id in <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">#{item}</foreach>
  694. </update>
  695. <update id="batchUpdateUserDept">
  696. UPDATE company_user
  697. SET dept_id = CASE user_id
  698. <foreach collection="companyUserList" item="item" separator=" ">
  699. WHEN #{item.userId} THEN #{item.deptId}
  700. </foreach>
  701. END
  702. WHERE user_id IN
  703. <foreach collection="companyUserList" item="item" open="(" separator="," close=")">
  704. #{item.userId}
  705. </foreach>
  706. </update>
  707. <select id="selectCompanyUserByCompanyUserId" resultMap="CompanyUserResult">
  708. select * from company_user where user_id = #{companyUserId}
  709. </select>
  710. <select id="selectCompanyByIpadStatus" resultType="com.fs.company.vo.QwIpadTotalVo">
  711. select company_id companyId,company_name companyName,
  712. sum(bind_count) bindCount,stat_time statTime from qw_ipad_total
  713. <where>
  714. <if test="dateTime != null">
  715. and stat_time like concat(#{dateTime}, '%')
  716. </if>
  717. </where>
  718. group by company_id,company_name
  719. </select>
  720. <select id="selectCompanyByIpadStatusCount" resultType="com.fs.company.vo.QwIpadTotalVo">
  721. SELECT qw.company_id companyId,c.company_name companyName,count(1) bindCount
  722. FROM `qw_user` qw left join company c on qw.company_id = c.company_id
  723. where qw.ipad_status is not null
  724. GROUP BY qw.company_id
  725. </select>
  726. <update id="updateAllowedAllRegister" parameterType="Long">
  727. update company_user
  728. set is_allowed_all_register = #{status} where user_id in
  729. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  730. #{userId}
  731. </foreach>
  732. </update>
  733. <select id="selectCompanyUserNameByIdsList" resultType="java.lang.String">
  734. SELECT nick_name from company_user where user_id in
  735. <foreach collection="companyUserIDs" item="id" open="(" separator="," close=")">
  736. #{id}
  737. </foreach>
  738. </select>
  739. <!-- 批量更新公司用户的绑定销售ID -->
  740. <update id="batchUpdateBindCompanyUserId">
  741. update fs_user
  742. set bind_company_user_id = #{bindCompanyUserId}
  743. where user_id in
  744. <foreach collection="userIds" item="userId" open="(" separator="," close=")">
  745. #{userId}
  746. </foreach>
  747. </update>
  748. <update id="updateVcCompanyUser">
  749. update vc_company_user
  750. set upload_url = #{vcCompanyUser.uploadUrl},
  751. times = #{vcCompanyUser.times},
  752. upload_time = #{vcCompanyUser.uploadTime},
  753. latest_text_to_speech_url = #{vcCompanyUser.latestTextToSpeechUrl}
  754. where company_user_id = #{vcCompanyUser.companyUserId}
  755. </update>
  756. <!-- 根据销售ID查询绑定的fs_user用户列表 -->
  757. <select id="selectBoundFsUsersByCompanyUserId" resultType="com.fs.hisStore.domain.FsUserScrm">
  758. SELECT *
  759. FROM fs_user
  760. WHERE bind_company_user_id = #{companyUserId}
  761. AND is_del = 0
  762. </select>
  763. <select id="selectCompanyUserByQwUserId" resultType="com.fs.company.domain.CompanyUser">
  764. SELECT * FROM company_user
  765. WHERE FIND_IN_SET(#{qwUserId}, qw_user_id) > 0
  766. order by create_time desc
  767. limit 1
  768. </select>
  769. <select id="selectVcCompanyUserByCompanyUserId" resultType="com.fs.company.param.VcCompanyUser">
  770. select
  771. id,times,speaker_id,upload_url,upload_time,company_user_id,latest_text_to_speech_url,version_id
  772. from
  773. vc_company_user
  774. where company_user_id = #{companyUserId}
  775. </select>
  776. <update id="unbindCidServer" parameterType="java.lang.Long" >
  777. update company_user
  778. set cid_server_id = null
  779. where user_id = #{companyUserId}
  780. </update>
  781. <select id="getSalesAppDownloadStats1" resultType="com.fs.qw.dto.SalesAppDownloadStatDTO">
  782. <if test="param.qwUserIds != null and param.qwUserIds.size() > 0">
  783. SELECT
  784. qw.qw_user_id,
  785. qw.company_user_id,
  786. qw.qw_user_name as corpName,
  787. cu.nick_name,
  788. cu.dept_id,
  789. IFNULL(cust.totalCustomers, 0) AS totalCustomers,
  790. IFNULL(cust.downloadCount, 0) AS downloadCount,
  791. IFNULL(cust.totalCustomers, 0) - IFNULL(cust.downloadCount, 0) AS notDownloadCount,
  792. (SELECT COUNT(*)
  793. FROM qw_external_contact ec2
  794. WHERE ec2.qw_user_id = qw.id
  795. AND ec2.create_time &lt;= #{param.statDate}) AS externalTotal
  796. FROM qw_user qw
  797. inner JOIN company_user cu
  798. ON qw.company_user_id = cu.user_id
  799. LEFT JOIN (
  800. SELECT
  801. ec.qw_user_id,
  802. COUNT(*) AS totalCustomers,
  803. SUM(u.history_app IS NOT NULL) AS downloadCount
  804. FROM qw_external_contact ec
  805. LEFT JOIN fs_user u
  806. ON u.user_id = ec.fs_user_id
  807. and u.first_login_time &lt;= #{param.statDate}
  808. WHERE ec.qw_user_id IN
  809. <foreach collection="param.qwUserIds" item="id" open="(" separator="," close=")">
  810. #{id}
  811. </foreach>
  812. AND ec.fs_user_id IS NOT NULL
  813. AND ec.create_time &lt;= #{param.statDate}
  814. GROUP BY ec.qw_user_id
  815. ) AS cust
  816. ON qw.id = cust.qw_user_id
  817. WHERE qw.id IN
  818. <foreach collection="param.qwUserIds" item="id" open="(" separator="," close=")">
  819. #{id}
  820. </foreach>
  821. and qw.corp_id = #{param.corpId}
  822. <if test="param.companyUserName != null and param.companyUserName != ''">
  823. AND cu.nick_name LIKE CONCAT('%', #{param.companyUserName}, '%')
  824. </if>
  825. <if test="param.qwUserName != null and param.qwUserName != ''">
  826. AND qw.qw_user_name LIKE CONCAT('%', #{param.qwUserName}, '%')
  827. </if>
  828. <if test="param.deptIds != null and param.deptIds.size() > 0">
  829. and cu.dept_id IN
  830. <foreach collection="param.deptIds" item="deptId" open="(" separator="," close=")">
  831. #{deptId}
  832. </foreach>
  833. </if>
  834. order by qw.qw_user_name
  835. </if>
  836. <if test="param.qwUserIds == null or param.qwUserIds.size() == 0">
  837. SELECT
  838. cu.user_id,
  839. cu.dept_id,
  840. cu.nick_name,
  841. 0 AS totalCustomers,
  842. 0 AS downloadCount,
  843. 0 AS notDownloadCount,
  844. 0 AS externalTotal
  845. FROM company_user cu
  846. WHERE user_id = #{param.companyUserId}
  847. </if>
  848. </select>
  849. <select id="findCompanyUserOptions" resultType="com.fs.company.domain.CompanyUser">
  850. SELECT
  851. user_id AS userId,
  852. nick_name AS nickName
  853. FROM
  854. company_user
  855. WHERE
  856. del_flag = '0'
  857. <if test="keyword != null and keyword != ''">
  858. AND ( user_id = #{keyword} OR nick_name LIKE CONCAT('%', #{keyword}, '%') )
  859. </if>
  860. <if test="selectedId != null">
  861. OR user_id = #{selectedId}
  862. </if>
  863. ORDER BY
  864. create_time DESC
  865. LIMIT #{pageNumber}, #{pageSize}
  866. </select>
  867. </mapper>