AdminMapper.xml 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.goafanti.common.dao.AdminMapper">
  4. <resultMap type="com.goafanti.common.model.Admin" id="AdminMap">
  5. <result property="id" column="id" jdbcType="VARCHAR"/>
  6. <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
  7. <result property="name" column="name" jdbcType="VARCHAR"/>
  8. <result property="password" column="password" jdbcType="VARCHAR"/>
  9. <result property="email" column="email" jdbcType="VARCHAR"/>
  10. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  11. <result property="number" column="number" jdbcType="INTEGER"/>
  12. <result property="province" column="province" jdbcType="VARCHAR"/>
  13. <result property="position" column="position" jdbcType="VARCHAR"/>
  14. <result property="superiorId" column="superior_id" jdbcType="VARCHAR"/>
  15. <result property="city" column="city" jdbcType="VARCHAR"/>
  16. <result property="departmentId" column="department_id" jdbcType="VARCHAR"/>
  17. <result property="status" column="status" jdbcType="VARCHAR"/>
  18. <result property="userNo" column="user_no" jdbcType="VARCHAR"/>
  19. <result property="duty" column="duty" jdbcType="VARCHAR"/>
  20. <result property="district" column="district" jdbcType="VARCHAR"/>
  21. <result property="headPortraitUrl" column="head_portrait_url" jdbcType="VARCHAR"/>
  22. <result property="contactMobile" column="contact_mobile" jdbcType="VARCHAR"/>
  23. <result property="lastLoginTime" column="last_login_time" jdbcType="TIMESTAMP"/>
  24. <result property="openId" column="open_id" jdbcType="VARCHAR"/>
  25. <result property="type" column="type" jdbcType="INTEGER"/>
  26. <result property="reviewer" column="reviewer" jdbcType="VARCHAR"/>
  27. <result property="ambId" column="amb_id" jdbcType="VARCHAR"/>
  28. <result property="ambRole" column="amb_role" jdbcType="VARCHAR"/>
  29. <result property="ambManage" column="amb_manage" jdbcType="INTEGER"/>
  30. <result property="managerId" column="manager_id" jdbcType="VARCHAR"/>
  31. <result property="seniorStaff" column="senior_staff" jdbcType="INTEGER"/>
  32. <result property="publicPurview" column="public_purview" jdbcType="INTEGER"/>
  33. <result property="expenseOpenId" column="expense_open_id" jdbcType="VARCHAR"/>
  34. <result property="expenseSuperExamine" column="expense_super_examine" jdbcType="INTEGER"/>
  35. <result property="publicCarbonCopy" column="public_carbon_copy" jdbcType="VARCHAR"/>
  36. <result property="callNo" column="call_no" jdbcType="VARCHAR"/>
  37. <result property="teamId" column="team_id" jdbcType="INTEGER"/>
  38. </resultMap>
  39. <sql id="AdminAllSql">
  40. id, mobile, name, password, email, create_time, number, province, position, superior_id, city, department_id, status, user_no, duty, district, head_portrait_url, contact_mobile, last_login_time, open_id, type, reviewer, amb_id, amb_role, amb_manage, manager_id, senior_staff, public_purview, expense_open_id, expense_super_examine, public_carbon_copy, call_no, team_id
  41. </sql>
  42. <!--查询单个-->
  43. <select id="queryById" resultMap="AdminMap">
  44. select
  45. <include refid="AdminAllSql"/>
  46. from admin
  47. where id = #{id}
  48. </select>
  49. <!--新增所有列-->
  50. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  51. insert into admin(id,mobile, name, password, email, create_time, number, province, position, superior_id, city,
  52. department_id, status, user_no, duty, district, head_portrait_url, contact_mobile,
  53. last_login_time, open_id, type, reviewer, amb_id, amb_role, amb_manage, manager_id,
  54. senior_staff, public_purview, expense_open_id, expense_super_examine, public_carbon_copy,
  55. call_no, team_id)
  56. values (#{id},#{mobile}, #{name}, #{password}, #{email}, #{createTime}, #{number}, #{province}, #{position},
  57. #{superiorId}, #{city}, #{departmentId}, #{status}, #{userNo}, #{duty}, #{district}, #{headPortraitUrl},
  58. #{contactMobile}, #{lastLoginTime}, #{openId}, #{type}, #{reviewer}, #{ambId}, #{ambRole}, #{ambManage},
  59. #{managerId}, #{seniorStaff}, #{publicPurview}, #{expenseOpenId}, #{expenseSuperExamine},
  60. #{publicCarbonCopy}, #{callNo}, #{teamId})
  61. </insert>
  62. <insert id="insertBatch">
  63. insert into admin(mobile, name, password, email, create_time, number, province, position, superior_id, city,
  64. department_id, status, user_no, duty, district, head_portrait_url, contact_mobile, last_login_time, open_id,
  65. type, reviewer, amb_id, amb_role, amb_manage, manager_id, senior_staff, public_purview, expense_open_id,
  66. expense_super_examine, public_carbon_copy, call_no, team_id)
  67. values
  68. <foreach collection="entities" item="entity" separator=",">
  69. (#{entity.mobile}, #{entity.name}, #{entity.password}, #{entity.email}, #{entity.createTime},
  70. #{entity.number}, #{entity.province}, #{entity.position}, #{entity.superiorId}, #{entity.city},
  71. #{entity.departmentId}, #{entity.status}, #{entity.userNo}, #{entity.duty}, #{entity.district},
  72. #{entity.headPortraitUrl}, #{entity.contactMobile}, #{entity.lastLoginTime}, #{entity.openId},
  73. #{entity.type}, #{entity.reviewer}, #{entity.ambId}, #{entity.ambRole}, #{entity.ambManage},
  74. #{entity.managerId}, #{entity.seniorStaff}, #{entity.publicPurview}, #{entity.expenseOpenId},
  75. #{entity.expenseSuperExamine}, #{entity.publicCarbonCopy}, #{entity.callNo}, #{entity.teamId})
  76. </foreach>
  77. </insert>
  78. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  79. insert into admin(mobile, name, password, email, create_time, number, province, position, superior_id, city,
  80. department_id, status, user_no, duty, district, head_portrait_url, contact_mobile, last_login_time, open_id,
  81. type, reviewer, amb_id, amb_role, amb_manage, manager_id, senior_staff, public_purview, expense_open_id,
  82. expense_super_examine, public_carbon_copy, call_no, team_id)
  83. values
  84. <foreach collection="entities" item="entity" separator=",">
  85. (#{entity.mobile}, #{entity.name}, #{entity.password}, #{entity.email}, #{entity.createTime},
  86. #{entity.number}, #{entity.province}, #{entity.position}, #{entity.superiorId}, #{entity.city},
  87. #{entity.departmentId}, #{entity.status}, #{entity.userNo}, #{entity.duty}, #{entity.district},
  88. #{entity.headPortraitUrl}, #{entity.contactMobile}, #{entity.lastLoginTime}, #{entity.openId},
  89. #{entity.type}, #{entity.reviewer}, #{entity.ambId}, #{entity.ambRole}, #{entity.ambManage},
  90. #{entity.managerId}, #{entity.seniorStaff}, #{entity.publicPurview}, #{entity.expenseOpenId},
  91. #{entity.expenseSuperExamine}, #{entity.publicCarbonCopy}, #{entity.callNo})
  92. </foreach>
  93. on duplicate key update
  94. mobile = values(mobile),
  95. name = values(name),
  96. password = values(password),
  97. email = values(email),
  98. create_time = values(create_time),
  99. number = values(number),
  100. province = values(province),
  101. position = values(position),
  102. superior_id = values(superior_id),
  103. city = values(city),
  104. department_id = values(department_id),
  105. status = values(status),
  106. user_no = values(user_no),
  107. duty = values(duty),
  108. district = values(district),
  109. head_portrait_url = values(head_portrait_url),
  110. contact_mobile = values(contact_mobile),
  111. last_login_time = values(last_login_time),
  112. open_id = values(open_id),
  113. type = values(type),
  114. reviewer = values(reviewer),
  115. amb_id = values(amb_id),
  116. amb_role = values(amb_role),
  117. amb_manage = values(amb_manage),
  118. manager_id = values(manager_id),
  119. senior_staff = values(senior_staff),
  120. public_purview = values(public_purview),
  121. expense_open_id = values(expense_open_id),
  122. expense_super_examine = values(expense_super_examine),
  123. public_carbon_copy = values(public_carbon_copy),
  124. call_no = values(call_no),
  125. team_id = values(team_id)
  126. </insert>
  127. <!--通过主键修改数据-->
  128. <update id="update">
  129. update admin
  130. <set>
  131. <if test="mobile != null and mobile != ''">
  132. mobile = #{mobile},
  133. </if>
  134. <if test="name != null and name != ''">
  135. name = #{name},
  136. </if>
  137. <if test="password != null and password != ''">
  138. password = #{password},
  139. </if>
  140. <if test="email != null and email != ''">
  141. email = #{email},
  142. </if>
  143. <if test="createTime != null">
  144. create_time = #{createTime},
  145. </if>
  146. <if test="number != null">
  147. number = #{number},
  148. </if>
  149. <if test="province != null and province != ''">
  150. province = #{province},
  151. </if>
  152. <if test="position != null and position != ''">
  153. position = #{position},
  154. </if>
  155. <if test="superiorId != null and superiorId != ''">
  156. superior_id = #{superiorId},
  157. </if>
  158. <if test="city != null and city != ''">
  159. city = #{city},
  160. </if>
  161. <if test="departmentId != null and departmentId != ''">
  162. department_id = #{departmentId},
  163. </if>
  164. <if test="status != null and status != ''">
  165. status = #{status},
  166. </if>
  167. <if test="userNo != null and userNo != ''">
  168. user_no = #{userNo},
  169. </if>
  170. <if test="duty != null and duty != ''">
  171. duty = #{duty},
  172. </if>
  173. <if test="district != null and district != ''">
  174. district = #{district},
  175. </if>
  176. <if test="headPortraitUrl != null and headPortraitUrl != ''">
  177. head_portrait_url = #{headPortraitUrl},
  178. </if>
  179. <if test="contactMobile != null and contactMobile != ''">
  180. contact_mobile = #{contactMobile},
  181. </if>
  182. <if test="lastLoginTime != null">
  183. last_login_time = #{lastLoginTime},
  184. </if>
  185. <if test="openId != null and openId != ''">
  186. open_id = #{openId},
  187. </if>
  188. <if test="type != null">
  189. type = #{type},
  190. </if>
  191. <if test="reviewer != null and reviewer != ''">
  192. reviewer = #{reviewer},
  193. </if>
  194. <if test="ambId != null and ambId != ''">
  195. amb_id = #{ambId},
  196. </if>
  197. <if test="ambRole != null and ambRole != ''">
  198. amb_role = #{ambRole},
  199. </if>
  200. <if test="ambManage != null">
  201. amb_manage = #{ambManage},
  202. </if>
  203. <if test="managerId != null and managerId != ''">
  204. manager_id = #{managerId},
  205. </if>
  206. <if test="seniorStaff != null">
  207. senior_staff = #{seniorStaff},
  208. </if>
  209. <if test="publicPurview != null">
  210. public_purview = #{publicPurview},
  211. </if>
  212. <if test="expenseOpenId != null and expenseOpenId != ''">
  213. expense_open_id = #{expenseOpenId},
  214. </if>
  215. <if test="expenseSuperExamine != null">
  216. expense_super_examine = #{expenseSuperExamine},
  217. </if>
  218. <if test="publicCarbonCopy != null and publicCarbonCopy != ''">
  219. public_carbon_copy = #{publicCarbonCopy},
  220. </if>
  221. <if test="callNo != null and callNo != ''">
  222. call_no = #{callNo},
  223. </if>
  224. <if test="teamId != null">
  225. team_id = #{teamId},
  226. </if>
  227. </set>
  228. where id = #{id}
  229. </update>
  230. <!--通过主键删除-->
  231. <delete id="deleteById">
  232. delete
  233. from admin
  234. where id = #{id}
  235. </delete>
  236. <select id="selectAllAdmin" resultMap="AdminMap">
  237. select
  238. <include refid="AdminAllSql" />
  239. from admin
  240. where status ='0'
  241. <if test="depId != null">
  242. and department_id = #{depId,jdbcType=VARCHAR}
  243. </if>
  244. </select>
  245. <select id="selectByMobile" parameterType="java.lang.String" resultMap="AdminMap">
  246. select
  247. a.id,a.mobile,a.name,
  248. a.password,a.email,a.create_time,
  249. a.number,b.province ,a.position,
  250. a.superior_id,a.city,a.department_id,
  251. a.status,a.user_no,a.duty,
  252. a.district,a.head_portrait_url,a.contact_mobile,
  253. a.last_login_time,a.open_id,a.type,
  254. a.reviewer,a.amb_id,a.amb_role,
  255. a.amb_manage,a.manager_id,a.senior_staff,
  256. a.public_purview,a.expense_open_id,a.expense_super_examine,a.call_no
  257. from admin a left join department b on a.department_id=b.id
  258. left join district_glossory c on b.province=c.id
  259. where a.mobile = #{mobile,jdbcType=VARCHAR}
  260. </select>
  261. <select id="selectRolesByPrimaryKey" parameterType="java.lang.String" resultType="com.goafanti.common.model.Role">
  262. select r.role_name name, r.id, r.role_type type
  263. from role r
  264. left join user_role ur on ur.rid=r.id
  265. where ur.uid = #{uid,jdbcType=VARCHAR}
  266. </select>
  267. <select id="selectCognizanceConsultant" resultMap="AdminMap">
  268. select
  269. <include refid="AdminAllSql" />
  270. from admin
  271. where id <![CDATA[ <> ]]> '1'
  272. </select>
  273. <select id="selectCognizancePrincipal" resultMap="AdminMap">
  274. select a.id, a.name, a.position from admin a
  275. INNER JOIN user_role ur on a.id = ur.uid
  276. where ur.rid not in('1','2','3','4','5','6')
  277. group by a.id
  278. </select>
  279. <select id="selectPatentAuthor" resultMap="AdminMap">
  280. select a.id, a.name, a.position from admin a
  281. INNER JOIN user_role ur on a.id = ur.uid
  282. where ur.rid not in('1','2','3','4','5','6')
  283. group by a.id
  284. </select>
  285. <select id="selectPatentPrincipal" resultMap="AdminMap">
  286. select a.id, a.name, a.position from admin a
  287. INNER JOIN user_role ur on a.id = ur.uid
  288. where ur.rid not in('1','2','3','4','5','6')
  289. group by a.id
  290. </select>
  291. <select id="selectCopyrightConsultant" resultMap="AdminMap">
  292. select
  293. <include refid="AdminAllSql" />
  294. from admin
  295. where id <![CDATA[ <> ]]> '1'
  296. </select>
  297. <select id="selectCopyrightPrincipal" resultMap="AdminMap">
  298. select a.id, a.name, a.position from admin a
  299. INNER JOIN user_role ur on a.id = ur.uid
  300. where ur.rid not in('1','2','3','4','5','6')
  301. group by a.id
  302. </select>
  303. <select id="selectTechprojectConsultant" resultMap="AdminMap">
  304. select
  305. <include refid="AdminAllSql" />
  306. from admin
  307. where id <![CDATA[ <> ]]> '1'
  308. </select>
  309. <select id="selectTechprojectPrincipal" resultMap="AdminMap">
  310. select a.id, a.name, a.position from admin a
  311. INNER JOIN user_role ur on a.id = ur.uid
  312. where ur.rid not in('1','2','3','4','5','6')
  313. group by a.id
  314. </select>
  315. <select id="selectRoleByPrimaryKey" parameterType="java.lang.String" resultType="String">
  316. SELECT rid FROM user_role
  317. where uid = #{uid,jdbcType=VARCHAR}
  318. </select>
  319. <select id="selectAccoutManager" resultMap="AdminMap">
  320. select a.id, a.name, a.position from admin a
  321. INNER JOIN user_role ur on a.id = ur.uid
  322. where ur.rid = '4'
  323. </select>
  324. <select id="selectTechnician" resultMap="AdminMap">
  325. select a.id, a.name, a.position from admin a
  326. INNER JOIN user_role ur on a.id = ur.uid
  327. where ur.rid not in('1','2','3','4')
  328. group by a.id
  329. </select>
  330. <select id="selectSalesman" resultMap="AdminMap">
  331. select a.id, a.name, a.position from admin a
  332. INNER JOIN user_role ur on a.id = ur.uid
  333. where ur.rid in ('5', '6')
  334. </select>
  335. <select id="selectContractManager" resultMap="AdminMap">
  336. select a.id, a.name, a.position from admin a
  337. INNER JOIN user_role ur on a.id = ur.uid
  338. where ur.rid not in('1','2','3','4')
  339. group by a.id
  340. </select>
  341. <select id="selectTechBroder" resultMap="AdminMap">
  342. select
  343. u.rid as rolesId, a.name,a.id, a.position
  344. from user_role u
  345. left join admin a on a.id =u.uid
  346. left join role r on r.id =u.rid
  347. where
  348. r.role_name='技术经纪专员'
  349. </select>
  350. <select id="listAdminSelectBySuperAdmin" resultMap="AdminMap">
  351. select
  352. <include refid="AdminAllSql" />
  353. from admin
  354. where id <![CDATA[ <> ]]> '1'
  355. </select>
  356. <select id="listAdminSelectByAreaAdmin" resultMap="AdminMap">
  357. select
  358. a.id, a.name, a.mobile,
  359. a.create_time as createTime, a.number, aa.name as superior
  360. from admin a
  361. left join admin_location al on al.admin_id = a.id
  362. left join admin aa on aa.id = a.superior_id
  363. where 1 = 1
  364. <if test="provinceList != null and provinceList.size &gt; 0">
  365. and al.province in
  366. <foreach close=")" collection="provinceList" item="plist" open="(" separator=",">
  367. #{plist}
  368. </foreach>
  369. </if>
  370. <if test="cityList != null and cityList.size &gt; 0">
  371. and al.city in
  372. <foreach close=")" collection="cityList" item="clist" open="(" separator=",">
  373. #{clist}
  374. </foreach>
  375. </if>
  376. </select>
  377. <select id="findAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  378. select
  379. a.number, a.mobile, a.name,
  380. a.position, a.email, a.id,
  381. a.province,
  382. a.city,
  383. a.create_time as createTime,
  384. aa.name as superior,
  385. a.superior_id as superiorId,
  386. a.department_id as departmentId,
  387. date_format(a.last_login_time,'%Y-%m-%d %H:%i:%S') as lastLoginTime,
  388. dm.name as departmentName
  389. from admin a
  390. left join admin_location al on a.id = al.admin_id
  391. left join admin aa on aa.id = a.superior_id
  392. left join department dm on a.department_id = dm.id
  393. left join user_role x on x.uid=a.id
  394. left join `role` y on x.rid=y.id
  395. where a.id <![CDATA[ <> ]]> '1'
  396. <if test="roleName != null">
  397. where y.role_name= #{roleName,jdbcType=VARCHAR}
  398. </if>
  399. <if test="mobile != null">
  400. and a.mobile = #{mobile,jdbcType=VARCHAR}
  401. </if>
  402. <if test="name != null">
  403. and a.name = #{name,jdbcType=VARCHAR}
  404. </if>
  405. <if test="number != null">
  406. and a.number = #{number,jdbcType=INTEGER}
  407. </if>
  408. <if test="seniorStaff != null">
  409. and a.senior_staff = #{seniorStaff}
  410. </if>
  411. <if test="province != null">
  412. and a.province = #{province,jdbcType=VARCHAR}
  413. </if>
  414. order by a.last_login_time ,a.number
  415. <if test="page_sql!=null">
  416. ${page_sql}
  417. </if>
  418. </select>
  419. <select id="findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  420. select count(1) from admin
  421. where id <![CDATA[ <> ]]> '1'
  422. left join `role` y on x.rid=y.id
  423. where a.id <![CDATA[ <> ]]> '1'
  424. <if test="roleName != null">
  425. where y.role_name= #{roleName,jdbcType=VARCHAR}
  426. </if>
  427. <if test="mobile != null">
  428. and mobile = #{mobile,jdbcType=VARCHAR}
  429. </if>
  430. <if test="name != null">
  431. and name = #{name,jdbcType=VARCHAR}
  432. </if>
  433. <if test="number != null">
  434. and number = #{number,jdbcType=INTEGER}
  435. </if>
  436. <if test="seniorStaff != null">
  437. and a.senior_staff = #{seniorStaff}
  438. </if>
  439. <if test="province != null">
  440. and a.province = #{province,jdbcType=VARCHAR}
  441. </if>
  442. </select>
  443. <select id="listAdminByName" parameterType="java.lang.String" resultMap="AdminMap">
  444. select id,name from admin where name like concat('%',#{name},'%')
  445. <if test="status==0">
  446. and status= '0'
  447. </if>
  448. <if test="status==1">
  449. and status= '1'
  450. </if>
  451. </select>
  452. <!--*************************************************************************-->
  453. <select id="selectAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  454. select a.id, a.mobile, a.name, a.position, a.email, a.province, a.city, a.create_time as createTime, aa.name as superior,dep.name departmentName,
  455. a.superior_id as superiorId, a.department_id as departmentId, a.last_login_time as lastLoginTime, a.contact_mobile as contactMobile,st.name teamName,a.team_id teamId,
  456. a.duty,a.status, a.type, ambs.id ambId,ambs.name ambName,ambs.ancestors_names ancestorsNames ,a.amb_role ambRole,a.senior_staff seniorStaff,a.public_purview publicPurview
  457. from admin a
  458. left join admin_location al on a.id = al.admin_id
  459. left join admin aa on aa.id = a.superior_id
  460. left join amb_system ambs on a.amb_id=ambs.id
  461. left join department dep on a.department_id = dep.id
  462. left join sales_team st on a.team_id=st.id
  463. <if test="rid != null">
  464. RIGHT join (select uid from user_role where rid=#{rid,jdbcType=VARCHAR}) ur on a.id=ur.uid
  465. </if>
  466. <if test="roleName != null">
  467. left join user_role ur on a.id=ur.uid
  468. RIGHT join (select id from role where role_name =#{roleName,jdbcType=VARCHAR}) y on ur.rid=y.id
  469. </if>
  470. where a.status in (0,1)
  471. <if test="name != null">
  472. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  473. </if>
  474. <if test="departmentId != null">
  475. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  476. </if>
  477. <if test="duty != null">
  478. and a.duty = #{duty,jdbcType=VARCHAR}
  479. </if>
  480. <if test="position != null">
  481. and a.position = #{position,jdbcType=VARCHAR}
  482. </if>
  483. <if test="status != null">
  484. and a.status = #{status,jdbcType=VARCHAR}
  485. </if>
  486. <if test="mobile != null">
  487. and a.mobile = #{mobile,jdbcType=VARCHAR}
  488. </if>
  489. <if test="superiorId != null">
  490. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  491. </if>
  492. <if test="ambId != null">
  493. and a.amb_id = #{ambId}
  494. </if>
  495. <if test="seniorStaff != null">
  496. and a.senior_staff = #{seniorStaff}
  497. </if>
  498. <if test="publicPurview != null">
  499. and a.public_purview = #{publicPurview}
  500. </if>
  501. <if test="ancestors != null">
  502. and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
  503. </if>
  504. <if test="ambManage !=null">
  505. and a.amb_manage= #{ambManage}
  506. </if>
  507. order by a.last_login_time desc
  508. <if test="page_sql!=null">
  509. ${page_sql}
  510. </if>
  511. </select>
  512. <select id="selectAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  513. select count(*)
  514. from admin a
  515. left join admin_location al on a.id = al.admin_id
  516. left join admin aa on aa.id = a.superior_id
  517. left join amb_system ambs on a.amb_id=ambs.id
  518. left join department dep on a.department_id = dep.id
  519. <if test="rid != null">
  520. RIGHT join (select * from user_role where rid=#{rid,jdbcType=VARCHAR}) ur on a.id=ur.uid
  521. </if>
  522. <if test="roleName != null">
  523. left join user_role ur on a.id=ur.uid
  524. RIGHT join (select * from role where role_name =#{roleName,jdbcType=VARCHAR}) y on ur.rid=y.id
  525. </if>
  526. where a.status in (0,1)
  527. <if test="name != null">
  528. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  529. </if>
  530. <if test="departmentId != null">
  531. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  532. </if>
  533. <if test="duty != null">
  534. and a.duty = #{duty,jdbcType=VARCHAR}
  535. </if>
  536. <if test="position != null">
  537. and a.position = #{position,jdbcType=VARCHAR}
  538. </if>
  539. <if test="status != null">
  540. and a.status = #{status,jdbcType=VARCHAR}
  541. </if>
  542. <if test="mobile != null">
  543. and a.mobile = #{mobile,jdbcType=VARCHAR}
  544. </if>
  545. <if test="superiorId != null">
  546. and a.superior_id = #{superiorId,jdbcType=VARCHAR}
  547. </if>
  548. <if test="ambId != null">
  549. and a.amb_id = #{ambId}
  550. </if>
  551. <if test="seniorStaff != null">
  552. and a.senior_staff = #{seniorStaff}
  553. </if>
  554. <if test="publicPurview != null">
  555. and a.public_purview = #{publicPurview}
  556. </if>
  557. <if test="ancestors != null">
  558. and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
  559. </if>
  560. <if test="ambManage !=null">
  561. and a.amb_manage= #{ambManage}
  562. </if>
  563. </select>
  564. <insert id="insertn" parameterType="com.goafanti.common.model.Admin">
  565. insert into admin (id, mobile, name,
  566. password, email, create_time,
  567. number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile,type)
  568. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  569. #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  570. #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
  571. #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
  572. #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR},
  573. #{type})
  574. </insert>
  575. <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
  576. select
  577. user_no as userNo
  578. from admin
  579. where
  580. id=#{superiorId,jdbcType=VARCHAR}
  581. </select>
  582. <select id="selectCountBySuperiorId" parameterType="java.lang.String" resultType="java.lang.Integer">
  583. select
  584. count(1)
  585. from admin
  586. where
  587. superior_id=#{superiorId,jdbcType=VARCHAR}
  588. </select>
  589. <select id="selectIdByUserNo" parameterType="java.lang.String" resultType="java.lang.String">
  590. select
  591. id
  592. from admin
  593. where
  594. user_no=#{UserNo,jdbcType=VARCHAR}
  595. </select>
  596. <select id="selectAllByid" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
  597. select a.id, a.mobile, a.name, a.`password`, a.email, a.create_time as createTime,a.call_no callNo,
  598. a.province, a.`position`,a.reviewer , a.superior_id as superiorId,a.public_purview publicPurview,
  599. a.department_id as departmentId, a.status,a.user_no as userNo,a.duty,a.district,a.expense_super_examine expenseSuperExamine,
  600. a.head_portrait_url as headPortraitUrl, a.contact_mobile as contactMobile,a.senior_staff seniorStaff,
  601. b.name superior,c.name reviewerName,a.type,a.amb_id ambId,a.manager_id managerId ,d.name managerName,
  602. a.public_carbon_copy publicCarbonCopy,e.name publicCarbonCopyName,a.team_id teamId,st.name teamName
  603. from admin a left join admin b on a.superior_id =b.id left join admin c on a.reviewer =c.id
  604. left join admin d on a.manager_id=d.id left join admin e on a.public_carbon_copy=e.id
  605. left join sales_team st on a.team_id=st.id
  606. where a.id= #{id,jdbcType=VARCHAR}
  607. </select>
  608. <select id="selectNameByid" parameterType="java.lang.String" resultType="java.lang.String">
  609. select
  610. name
  611. from admin
  612. where
  613. id=#{id,jdbcType=VARCHAR}
  614. </select>
  615. <select id="selectRolesByUid" parameterType="com.goafanti.common.model.Role" resultType="com.goafanti.common.model.Role">
  616. select
  617. r.id,r.role_name as roleName
  618. from user_role ur
  619. left join role r on r.id = ur.rid
  620. where
  621. uid=#{id,jdbcType=VARCHAR}
  622. </select>
  623. <select id="selectStatusByMobile" parameterType="java.lang.String" resultType="java.lang.String">
  624. select
  625. status
  626. from admin
  627. where
  628. mobile= #{mobile,jdbcType=VARCHAR}
  629. </select>
  630. <select id="selectIDNBySuperiorId" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
  631. select id, mobile, name,
  632. password, email, create_time as createTime,
  633. province, position,
  634. superior_id as superiorId,department_id as departmentId,
  635. status,user_no as userNo,duty,district,head_portrait_url as headPortraitUrl
  636. from admin
  637. where
  638. superior_id=#{superiorId,jdbcType=VARCHAR}
  639. </select>
  640. <select id="selectUserNoById" resultType="java.lang.String">
  641. select user_no as userNo
  642. from admin
  643. where
  644. id=#{superiorId,jdbcType=VARCHAR}
  645. </select>
  646. <update id="updateByUserNo" parameterType="com.goafanti.common.model.Admin">
  647. update admin
  648. set user_no = #{userNo,jdbcType=VARCHAR}
  649. where
  650. id=#{id,jdbcType=VARCHAR}
  651. </update>
  652. <select id="selectIdBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
  653. select id
  654. from admin
  655. where
  656. superior_id=#{superiorId,jdbcType=VARCHAR}
  657. </select>
  658. <select id="selectSubList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  659. select
  660. a.id,
  661. a.user_no as userNo,
  662. a.mobile,
  663. a.name,
  664. a.position,
  665. b.name as departmentName
  666. from
  667. admin a left join department b on
  668. a.department_id = b.id
  669. where
  670. a.department_id =(
  671. select
  672. department_id
  673. from
  674. admin
  675. where
  676. id = #{adminId,jdbcType=VARCHAR}
  677. )
  678. and a.id <![CDATA[ <> ]]> #{adminId,jdbcType=VARCHAR}
  679. </select>
  680. <select id="selectAdminByRoleId" parameterType="java.lang.String" resultMap="AdminMap">
  681. select a.id,a.name from admin a left join user_role b on a.id = b.uid left join role c on b.rid = c.id where c.id = #{roleId,jdbcType=VARCHAR} limit 1
  682. </select>
  683. <select id="selectDepartmentStaff" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  684. select a.id ,a.name,a.password,a.department_id,b.name
  685. from admin a left join department b
  686. on a.department_id= b.id
  687. where 1=1
  688. <if test="departmentId != null and departmentId !='' ">
  689. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  690. </if>
  691. <if test="name != null">
  692. and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
  693. </if>
  694. </select>
  695. <select id="selectAdminName" parameterType="java.lang.String" resultMap="AdminMap">
  696. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  697. left join `role` c on b.rid=c.id
  698. where c.role_name = #{name,jdbcType=VARCHAR}
  699. </select>
  700. <update id="updateLockIds" parameterType="java.lang.String">
  701. update admin set status = '1' where id in (${lockIds})
  702. </update>
  703. <!-- 用户是为正常的 -->
  704. <select id="getCountById" parameterType="java.lang.String" resultType="java.lang.Integer">
  705. select count(a.id) from admin a
  706. inner join user_role ur on a.id=ur.uid
  707. where a.id= #{_parameter,jdbcType=VARCHAR} and ( a.status != '注销' or a.status is null)
  708. </select>
  709. <select id="getAdminRoleNameList" parameterType="java.lang.String" resultMap="AdminMap">
  710. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  711. left join `role` c on b.rid=c.id
  712. where c.role_name = #{name,jdbcType=VARCHAR} and a.status= 0
  713. </select>
  714. <select id="getAdminRoleNamesList" parameterType="java.lang.String" resultMap="AdminMap">
  715. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  716. left join `role` c on b.rid=c.id
  717. where a.status= 0
  718. and c.role_name in
  719. <foreach close=")" collection="list" item="name" open="(" separator=",">
  720. #{name}
  721. </foreach>
  722. </select>
  723. <select id="getAdminRoleTypeList" parameterType="java.lang.String" resultMap="AdminMap">
  724. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  725. left join `role` c on b.rid=c.id
  726. where c.role_type = #{roleType} and a.status= 0
  727. </select>
  728. <select id="getAdminRoleTypesList" parameterType="java.lang.String" resultMap="AdminMap">
  729. select a.id, a.name from admin a left join user_role b on a.id=b.uid
  730. left join `role` c on b.rid=c.id
  731. where a.status= 0
  732. and c.role_type in
  733. <foreach close=")" collection="list" item="type" open="(" separator=",">
  734. #{type}
  735. </foreach>
  736. </select>
  737. <select id="getDeptNameByAid" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  738. select a.id,a.name, d.name as departmentName,a.department_id departmentId,a.email,a.superior_id superiorId,a.open_id openId,
  739. a.reviewer,d.manager_id depManager,d.finance_id depFinance,a.public_purview publicPurview,a.expense_super_examine expenseSuperExamine,
  740. a.public_carbon_copy publicCarbonCopy
  741. from admin a left join department d on a.department_id = d.id
  742. where a.id = #{_parameter,jdbcType=VARCHAR}
  743. </select>
  744. <insert id="addAdminContacts" parameterType="com.goafanti.admin.bo.AdminContacts">
  745. insert into admin_contacts (id,aid,contacts_id)values
  746. (#{id,jdbcType=VARCHAR},#{aid,jdbcType=VARCHAR},#{contactsId,jdbcType=VARCHAR})
  747. </insert>
  748. <select id="frequentContactsList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
  749. select a.id,b.id as contactId,b.name,b.position,b.contact_mobile as contactMobile,c.name as departmentName,y.role_name as roleName
  750. from admin_contacts a left join admin b
  751. on a.contacts_id=b.id left join department c
  752. on c.id=b.department_id left join user_role x on x.uid=b.id
  753. left join `role` y on x.rid=y.id
  754. where b.status ='0'
  755. <if test="roleName != null">
  756. and y.role_name= #{roleName,jdbcType=VARCHAR}
  757. </if>
  758. <if test="aid != null">
  759. and a.aid= #{aid,jdbcType=VARCHAR}
  760. </if>
  761. <if test="name != null">
  762. and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  763. </if>
  764. <if test="deps != null">
  765. and b.department_id in
  766. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  767. #{depId}
  768. </foreach>
  769. </if>
  770. <if test="page_sql!=null">
  771. ${page_sql}
  772. </if>
  773. </select>
  774. <select id="frequentContactsCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  775. select count(*)
  776. from admin_contacts a left join admin b
  777. on a.contacts_id=b.id
  778. left join user_role x on x.uid=b.id
  779. left join `role` y on x.rid=y.id
  780. where b.status ='0'
  781. <if test="roleName != null">
  782. and y.role_name= #{roleName,jdbcType=VARCHAR}
  783. </if>
  784. <if test="aid != null">
  785. and a.aid= #{aid,jdbcType=VARCHAR}
  786. </if>
  787. <if test="name != null">
  788. and b.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  789. </if>
  790. <if test="deps != null">
  791. and b.department_id in
  792. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  793. #{depId}
  794. </foreach>
  795. </if>
  796. </select>
  797. <delete id="deleteFrequentContacts" parameterType="java.lang.String">
  798. delete from admin_contacts
  799. where id = #{id,jdbcType=VARCHAR}
  800. </delete>
  801. <select id="getaidFrequentContacts" resultType="java.lang.String">
  802. select b.id from admin_contacts a left join admin b on a.contacts_id = b.id
  803. where b.status = '0' and a.aid= #{id,jdbcType=VARCHAR}
  804. </select>
  805. <select id="selectAdminCustomerList" resultType="com.goafanti.admin.bo.AdminCustomerBo">
  806. select a.id as aid,a.name as aName,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(c.inputCount,0) as newCount,
  807. ifnull(c.receiveCount,0) as receiveCount,ifnull(b.signCount,0) as signCount,ifnull(c.transferCount,0) as transferCount
  808. from admin a
  809. left join (select aid, sum(if(share_type=0 and source in (1,2,3),1,0))userCount,
  810. sum(if(share_type=2,1,0))signCount from `user` where type=1 and new_channel=0
  811. group by aid) b on a.id=b.aid
  812. left join (select aid, sum(if(share_type=0 and source in (1),1,0))inputCount,
  813. sum(if(share_type=0 and source in (3),1,0))transferCount, sum(if(share_type=0 and source in (2),1,0))receiveCount
  814. from `user` where type=1 and new_channel=0
  815. <if test="startTime != null and endTime != null">
  816. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  817. </if>
  818. group by aid) c on a.id=c.aid
  819. left join department d on a.department_id=d.id
  820. left join user_role e on a.id=e.uid
  821. left join `role` f on e.rid=f.id
  822. where f.role_type in (96,996)
  823. and a.status= 0
  824. <if test="depId != null">
  825. and a.department_id = #{depId,jdbcType=VARCHAR}
  826. </if>
  827. <if test="page_sql!=null">
  828. ${page_sql}
  829. </if>
  830. </select>
  831. <select id="selectAdminCustomerCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  832. select count(*) from admin a
  833. left join department d on a.department_id=d.id
  834. left join user_role e on a.id=e.uid
  835. left join `role` f on e.rid=f.id
  836. where f.role_type in (96,996)
  837. and a.status= 0
  838. <if test="depId != null">
  839. and a.department_id = #{depId,jdbcType=VARCHAR}
  840. </if>
  841. </select>
  842. <select id="selectAdminCustomerDetailList" resultType="com.goafanti.admin.bo.AdminCustomerDetailBo">
  843. select a.id,a.nickname as name,a.source,c.contacts contacts,c.contact_mobile as contactMobile,c.contacts_dep contactsDep,
  844. c.contacts_position contactsPosition, a.create_time as createTime,b.last_follow_time as followTime,c.location_province locationProvince,
  845. c.location_city locationCity,c.location_area locationArea,c.business_scope businessScope , c.intended_project intendedProject
  846. from user a left join (select uid,last_follow_time from user_mid where aid= #{aid}) b on a.id=b.uid
  847. left join organization_identity c on a.id=c.uid
  848. <if test="type==5 or type==6">
  849. left join (select aid,uid from public_release a left join public_release_details b on a.id=b.prid
  850. where b.clock_in =1
  851. and aid= #{aid,jdbcType=VARCHAR}
  852. <if test="startTime != null and endTime != null">
  853. and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  854. </if>
  855. )e on a.id=e.uid
  856. </if>
  857. where a.type=1 and a.new_channel=0
  858. <include refid="AdminCustomerDetailSql"/>
  859. <if test="page_sql!=null">
  860. ${page_sql}
  861. </if>
  862. </select>
  863. <sql id="AdminCustomerDetailSql">
  864. <if test="type != 5 and type !=6">
  865. and a.aid= #{aid,jdbcType=VARCHAR}
  866. </if>
  867. <if test="type == 5 or type ==6">
  868. and e.aid= #{aid,jdbcType=VARCHAR}
  869. </if>
  870. <if test="type == 0">
  871. and a.share_type = 0
  872. </if>
  873. <if test="type == 1">
  874. and a.share_type = 3
  875. </if>
  876. <if test="type ==0 or type==3 or type==5 or type==7 or type ==8">
  877. and a.channel=0
  878. </if>
  879. <if test="type == 1 or type==4 or type==6">
  880. and a.channel=1
  881. </if>
  882. <if test="type == 2">
  883. and a.share_type=2
  884. </if>
  885. <if test="type == 3 or type==4">
  886. and a.source=1
  887. and a.share_type = 0
  888. </if>
  889. <if test="type==7 ">
  890. and a.share_type = 0
  891. and a.source=2
  892. </if>
  893. <if test="type == 8">
  894. and a.share_type = 0
  895. and a.source=3
  896. </if>
  897. <if test="type!=5 and type!=6">
  898. <if test="startTime != null and endTime != null">
  899. and a.transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  900. </if>
  901. </if>
  902. </sql>
  903. <select id="selectAdminCustomerDetailCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  904. select count(*)
  905. from user a
  906. <if test="type==5 or type==6">
  907. left join (select aid,uid from public_release a left join public_release_details b on a.id=b.prid
  908. where b.clock_in =1
  909. and aid= #{aid,jdbcType=VARCHAR}
  910. <if test="startTime != null and endTime != null">
  911. and clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  912. </if>
  913. )e on a.id=e.uid
  914. </if>
  915. where a.type=1 and a.new_channel=0
  916. <include refid="AdminCustomerDetailSql"/>
  917. </select>
  918. <select id="listNameByDepAndName" resultType="java.lang.String">
  919. select a.id from admin a left join user_role b on a.id =b.uid
  920. left join `role` c on b.rid=c.id
  921. where department_id= #{depId}
  922. and c.role_type= #{roleType}
  923. </select>
  924. <select id="listAdminBydepIdAndRoleType" resultType="com.goafanti.common.model.Admin">
  925. select a.id,a.name,a.email ,a.open_id openId,a.expense_open_id expenseOpenId
  926. from admin a left join user_role b on a.id =b.uid left join `role` c on b.rid=c.id
  927. where a.status='0'
  928. and a.department_id= #{depId}
  929. and c.role_type= #{roleType}
  930. </select>
  931. <select id="selectBySuperId" resultType="java.lang.String">
  932. select id from admin where superior_id= #{aid}
  933. </select>
  934. <select id="selectMyAndSuperBySuperId" parameterType="java.lang.String" resultType="com.goafanti.common.bo.AdminNoticeBo">
  935. select
  936. a.id,a.name,a.email,a.open_id openId,a.expense_open_id expenseOpenId,a.expense_super_examine expenseSuperExamine,
  937. b.id superId,b.name superName,b.email superEmail,b.open_id superOpenId,b.expense_open_id superExpenseOpenId
  938. from admin a left join admin b on a.superior_id=b.id
  939. where a.id=#{id}
  940. </select>
  941. <select id="selectFinanceAdminByOrderDep" resultType="com.goafanti.common.model.Admin">
  942. select a.finance_id id,b.name from department a left join admin b on a.finance_id=b.id
  943. where a.id= #{orderDep}
  944. </select>
  945. <select id="getPermission" resultType="java.lang.String">
  946. select c.role_type from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid=c.id
  947. where a.id= #{transferId}
  948. </select>
  949. <select id="selectDepIdWithSpuerId" resultType="java.lang.String">
  950. select b.id from admin a right join department b on a.id=b.finance_id
  951. where a.superior_id= #{superId}
  952. </select>
  953. <select id="getAdminRoleListByAid" resultType="java.lang.String">
  954. select c.role_type from admin a left join user_role b on a.id=b.uid
  955. left join role c on b.rid =c.id
  956. where a.id= #{id}
  957. </select>
  958. <select id="selectByOpeid" parameterType="java.lang.String" resultMap="AdminMap">
  959. select
  960. <include refid="AdminAllSql" />
  961. from admin
  962. where open_id= #{openid}
  963. </select>
  964. <select id="getFinanceDep" resultType="java.lang.String">
  965. select id from department where finance_id = #{aid}
  966. </select>
  967. <select id="getLowerFinanceDep" resultType="java.lang.String">
  968. select b.id from admin a left join department b on a.id=b.finance_id
  969. where a.superior_id = #{aid}
  970. </select>
  971. <select id="selectByAmbIdCount" resultType="java.lang.Integer">
  972. SELECT count(*) from admin where amb_id= #{ambId}
  973. </select>
  974. <select id="selectAdminByRoleType" parameterType="java.lang.String" resultType="com.goafanti.common.model.Admin">
  975. SELECT a.id,a.name ,a.mobile ,a.email,a.department_id departmentId,a.open_id openId,a.expense_open_id expenseOpenId
  976. FROM admin a left join user_role b on a.id=b.uid
  977. left join `role` c on b.rid =c.id
  978. where a.status='0'
  979. <if test="roleType =='99998'">
  980. and c.role_type in ('99998','99988')
  981. </if>
  982. <if test="roleType =='99999'">
  983. and c.role_type in ('99999','99989')
  984. </if>
  985. <if test="roleType =='99999888'">
  986. and c.role_type in ('99998','99988','99999','99989')
  987. </if>
  988. <if test="roleType !='99999' and roleType !='99998' and roleType !='99999888'">
  989. and c.role_type in (#{roleType})
  990. </if>
  991. </select>
  992. <select id="selectByDeps" resultType="com.goafanti.admin.bo.AdminCustomerBo">
  993. SELECT a.id aid,a.name aName,a.department_id depId,d.name depName
  994. from admin a left join department d on a.department_id = d.id
  995. where a.status =0 and a.`type` =1
  996. <if test="seniorStaff != null">
  997. and a.senior_staff=#{seniorStaff}
  998. </if>
  999. <if test="depIds!= null">
  1000. and a.department_id in
  1001. <foreach close=")" collection="depIds" item="deps" open="(" separator=",">
  1002. #{deps.id}
  1003. </foreach>
  1004. </if>
  1005. </select>
  1006. <select id="getAdminByFinanceId" resultType="com.goafanti.common.model.Admin">
  1007. select b.id ,b.name
  1008. from department a left join admin b on a.finance_id=b.id
  1009. where a.id= #{id}
  1010. </select>
  1011. <select id="selectRoleTypeByid" resultType="java.lang.Integer">
  1012. select b.role_type
  1013. from user_role a left join `role` b on a.rid =b.id
  1014. where a.uid = #{aid}
  1015. </select>
  1016. <select id="selectFinanceAdminByAid" resultType="com.goafanti.common.model.Admin">
  1017. select c.id,c.name,c.open_id openId,c.email
  1018. from admin a left join department b on a.department_id=b.id
  1019. left join admin c on b.finance_id=c.id
  1020. where a.id= #{aid}
  1021. </select>
  1022. <select id="adminStatisticsInfo" resultType="com.goafanti.admin.bo.AdminStatisticsBo">
  1023. select x.id aid,y.projectCheckSum,y.projectStopSum,g.orderSum,g.changeSum,
  1024. z.rejectSum,t.receivables
  1025. from admin x
  1026. left join(select a.salesman_id aid , sum(if( b.project_status =29,1,0))projectStopSum ,
  1027. sum(if(b.check_status=1,1,0))projectCheckSum from t_order_new a left join t_order_task b
  1028. on a.order_no =b.order_no where a.salesman_id = #{aid})y on x.id=y.aid
  1029. left join ( select salesman_id aid, sum(1)orderSum, sum(if(delete_sign=2,1,0))changeSum
  1030. from t_order_new where delete_sign in (0,2,3) and process_status >0
  1031. and salesman_id = #{aid})g on x.id=g.aid
  1032. left join ( select salesman_id aid, sum(if(order_status=3 or order_status=5,1,0))rejectSum
  1033. from t_order_new where delete_sign in (0,2,3)
  1034. and salesman_id = #{aid})z on x.id=z.aid
  1035. left join ( SELECT b.salesman_id aid ,sum(a.money) receivables
  1036. from new_order_dun a left join t_order_new b on a.order_no =b.order_no
  1037. where a.status =1 and b.delete_sign in (0,2,3)
  1038. and b.salesman_id = #{aid})t on x.id=t.aid
  1039. where x.id= #{aid}
  1040. </select>
  1041. <select id="adminStatisticsInfoByTime" resultType="com.goafanti.admin.bo.AdminStatisticsBo">
  1042. select sum(follow_count) rangeFollowSum,sum(order_count) rangeOrdersum
  1043. from admin_user_count a where aid=#{aid} and date_time BETWEEN #{startTime} and #{endTime}
  1044. group by aid
  1045. </select>
  1046. <select id="thisMonthUser" resultType="com.goafanti.common.model.AdminUserCount">
  1047. select id,aid,private_count privateCount,sign_count signCount,channel_count channelCount,public_release_count publicReleaseCount,
  1048. follow_count followCount,order_count orderCount, DATE_FORMAT(date_time , '%Y-%m-%d') dateTime
  1049. from admin_user_count
  1050. where date_time BETWEEN #{firstDay} and #{endDay}
  1051. and aid= #{aid}
  1052. order by date_time
  1053. </select>
  1054. <select id="selectAdminPublicRelease" resultType="com.goafanti.common.model.AdminUserCount">
  1055. select aid,count(*)publicReleaseCount, dates dateTime
  1056. from (select aid,DATE_FORMAT(a.release_start , '%Y-%m-%d') dates
  1057. from public_release a left join public_release_details b on a.id=b.prid
  1058. where status =2 and aid= #{aid})x
  1059. group by aid,dates
  1060. </select>
  1061. <select id="selectAdminUserFollow" resultType="com.goafanti.common.model.AdminUserCount">
  1062. select aid ,count(*)followCount, dateTime
  1063. from (select aid,DATE_FORMAT(create_time , '%Y-%m-%d') dateTime
  1064. from user_follow where aid= #{aid} )a
  1065. group by aid,dateTime
  1066. </select>
  1067. <select id="selectAdminOrder" resultType="com.goafanti.common.model.AdminUserCount">
  1068. select salesman_id aid ,count(*)orderCount, dateTime
  1069. from (select salesman_id, DATE_FORMAT(create_time , '%Y-%m-%d') dateTime
  1070. from t_order_new
  1071. where delete_sign in (0,2,3) and process_status >0
  1072. and salesman_id= #{aid} )x
  1073. group by salesman_id ,dateTime
  1074. </select>
  1075. <select id="adminStatisticsPublicReleaseByAidAndTime" resultType="java.lang.Integer">
  1076. select sum(1) rangePublicReleaseSum
  1077. from public_release a left join public_release_details b on a.id=b.prid
  1078. where status =2 and a.aid = #{aid}
  1079. and((a.release_start &gt; #{startTime} and a.release_start &lt; #{endTime})or
  1080. (a.release_end &gt; #{startTime} and a.release_end &lt; #{endTime})or
  1081. (a.release_start &lt; #{startTime} and a.release_end &gt; #{endTime}))
  1082. </select>
  1083. <select id="addAdminContactsRangeReceivables" resultType="java.math.BigDecimal">
  1084. SELECT ifnull(sum(a.money),0) receivables
  1085. from new_order_dun a left join t_order_new b on a.order_no =b.order_no
  1086. where a.status =1 and b.delete_sign in (0,2,3)
  1087. and b.salesman_id = #{aid}
  1088. and a.start_time between #{startTime} and #{endTime}
  1089. </select>
  1090. <select id="consultantStatisticsInfo" resultType="com.goafanti.admin.bo.ConsultantStatisticsBo">
  1091. SELECT x.aid,x.projectCount,x.inProgress,x.complete,x.notStarted,x.stop,y.countPublicRelease,y.countAssist,z.countChange,v.orderPayment
  1092. from (select a.task_receiver aid,sum(commodity_quantity) projectCount, sum(if(a.project_status=1,commodity_quantity,0)) inProgress,
  1093. sum(if(a.project_status in (19,27) ,commodity_quantity,0)) complete, sum(if(a.project_status=0,commodity_quantity,0)) notStarted,
  1094. sum(if(a.project_status in (2,3,29),commodity_quantity,0)) stop
  1095. from t_order_task a left join t_order_new b on a.order_no =b.order_no
  1096. where b.delete_sign in (0,2,3) and a.split_status in (0,2) and a.task_receiver = #{aid} group by a.task_receiver)x
  1097. left join (select aid,sum(if(a.`type` in (0,1,2),1,0)) countPublicRelease,sum(if(a.`type` in (3),1,0)) countAssist
  1098. from public_release a left join public_release_details b on a.id=b.prid where aid= #{aid})y on x.aid=y.aid
  1099. left join (SELECT b.aid,count(DISTINCT a.order_no) countChange from new_order_change a
  1100. left join order_examine b on a.order_no =b.order_no where 1=1
  1101. <if test="type==2">
  1102. and a.process_state in (3,4)
  1103. </if>
  1104. <if test="type==0">
  1105. and a.process_state in (3)
  1106. </if>
  1107. <if test="type==1">
  1108. and a.process_state in (4)
  1109. </if>
  1110. and b.aid=#{aid} and b.status =0 group by b.aid)z on x.aid=z.aid
  1111. LEFT join (select b.task_receiver aid, count(*) orderPayment from t_order_payment a
  1112. left join t_order_task b on a.tid=b.id left join t_order_new c on b.order_no=c.order_no
  1113. where b.task_receiver= #{aid} and a.status in(0,1,2) group by b.task_receiver )v on x.aid=v.aid
  1114. </select>
  1115. <select id="consultantStatisticsInfoByTime" resultType="com.goafanti.admin.bo.ConsultantStatisticsBo">
  1116. select a.id,x.projectCount,x.inProgress,x.notStarted,y.complete,y.stop,z.countPublicRelease,z.countAssist
  1117. from admin a left join (select a.task_receiver aid,sum(commodity_quantity) projectCount,
  1118. sum(if(a.project_status=1,commodity_quantity,0)) inProgress,
  1119. sum(if(a.project_status=0,commodity_quantity,0)) notStarted from t_order_task a where a.split_status in (0,2)
  1120. and a.task_receiver = #{aid} and a.task_distribution_time BETWEEN #{startTime} and #{endTime} group by a.task_receiver )x on a.id=x.aid
  1121. left join (SELECT a.task_receiver aid,sum(if(a.project_status in (19,27) ,commodity_quantity,0)) complete,
  1122. sum(if(a.project_status in (2,3,29),commodity_quantity,0)) stop from t_order_task a left join task_time b on a.id=b.tid
  1123. where a.split_status in (0,2) and b.project_status =a.project_status and a.task_receiver = #{aid}
  1124. and b.date_time BETWEEN #{startTime} and #{endTime} group by a.task_receiver )y on a.id=y.aid
  1125. left join (select aid,sum(if(a.`type` in (0,1,2),1,0)) countPublicRelease,sum(if(a.`type` in (3),1,0)) countAssist
  1126. from public_release a left join public_release_details b on a.id=b.prid where aid= #{aid} and a.status =2
  1127. and a.release_start BETWEEN #{startTime} and #{endTime} group by a.aid)z on a.id=z.aid
  1128. where a.id=#{aid}
  1129. </select>
  1130. <select id="consultantthisMonthUser" resultType="com.goafanti.admin.bo.ConsultantUserCount">
  1131. select x.dates,sum(projectCount)projectCount,sum(inProgress)inProgress,sum(notStarted)notStarted
  1132. ,0 complete,0 stop,0 countPublicRelease,0 countAssist
  1133. from (select commodity_quantity projectCount, if(a.project_status=1,commodity_quantity,0)inProgress,
  1134. if(a.project_status=0,commodity_quantity,0)notStarted,DATE_FORMAT(a.task_distribution_time,'%Y-%m-%d') dates
  1135. from t_order_task a where a.split_status in (0,2) and a.task_receiver = #{aid}
  1136. and a.task_distribution_time BETWEEN #{firstDay} and #{endDay})x
  1137. group by x.dates
  1138. union
  1139. select x.dates,0 projectCount,0 inProgress,0 notStarted,sum(complete)complete,sum(stop)stop,0,0
  1140. from (SELECT if(a.project_status in (19,27) ,commodity_quantity,0) complete,
  1141. if(a.project_status in (2,3,29),commodity_quantity,0) stop ,DATE_FORMAT(b.date_time ,'%Y-%m-%d') dates
  1142. from t_order_task a left join task_time b on a.id=b.tid
  1143. where a.split_status in (0,2) and b.project_status =a.project_status
  1144. and a.task_receiver = #{aid} and b.date_time BETWEEN #{firstDay} and #{endDay})x
  1145. group by x.dates
  1146. union
  1147. select x.dates,0,0,0,0,0,sum(countPublicRelease)countPublicRelease,sum(countAssist)countAssist
  1148. from ( select if(a.`type` in (0,1,2),1,0) countPublicRelease,if(a.`type` in (3),1,0) countAssist,
  1149. DATE_FORMAT(a.release_start ,'%Y-%m-%d') dates
  1150. from public_release a left join public_release_details b on a.id=b.prid where aid= #{aid}
  1151. and a.status =2
  1152. and a.release_start BETWEEN #{firstDay} and #{endDay})x
  1153. group by x.dates
  1154. </select>
  1155. <select id="selectOrderByFinanace" resultType="com.goafanti.common.model.Admin">
  1156. select c.id,c.name
  1157. from t_order_new a left join department b on a.order_dep=b.id
  1158. left join admin c on b.finance_id=c.id
  1159. where a.order_no =#{orderNo};
  1160. </select>
  1161. <select id="selectAdminByRoleTypes" resultType="com.goafanti.common.model.Admin">
  1162. SELECT a.id,a.name ,a.mobile ,a.email,a.department_id departmentId,a.open_id openId,a.expense_open_id expenseOpenId
  1163. FROM admin a left join user_role b on a.id=b.uid
  1164. left join `role` c on b.rid =c.id
  1165. where a.status='0'
  1166. and c.role_type in
  1167. <foreach collection="list" item="e" open="(" close=")" separator=",">
  1168. #{e}
  1169. </foreach>
  1170. </select>
  1171. <select id="financeInfo" resultType="com.goafanti.admin.bo.OutFinanceCount">
  1172. select x.aid,x.orderCount,x.expenseCount,x.invoiceCount,x.memberCount,x.paymentCount,b.counts publicCount,y.orderUnauditedCount,
  1173. c.counts receivables,y.expenseUnauditedCount,y.invoiceUnauditedCount,y.memberUnauditedCount,y.paymentUnauditedCount
  1174. from ( select a.aid,sum(a.order_count)orderCount ,sum(a.expense_count)expenseCount ,SUM(a.invoice_count) invoiceCount,
  1175. sum(a.member_count) memberCount ,sum(a.payment_count)paymentCount from finance_count a where a.aid= #{aid} )x
  1176. left join(select aid,sum(if(a.`type` in (0,1,2),1,0)) counts from public_release a left join public_release_details b on a.id=b.prid
  1177. where a.status=2 and a.aid= #{aid} )b on x.aid=b.aid
  1178. left join (SELECT c.finance_id aid,sum(a.money) counts from new_order_dun a left join t_order_new b on a.order_no =b.order_no
  1179. left join department c on b.order_dep =c.id where a.status =1 and b.delete_sign in (0,2,3) and c.finance_id = #{aid} )c on x.aid=c.aid
  1180. left join (select a.aid,sum(a.order_unaudited_count)orderUnauditedCount , sum(a.expense_unaudited_count)expenseUnauditedCount ,
  1181. SUM(a.invoice_unaudited_count) invoiceUnauditedCount, sum(a.member_unaudited_count) memberUnauditedCount ,
  1182. sum(a.payment_unaudited_count)paymentUnauditedCount from finance_count a where a.aid= #{aid}
  1183. and a.date_time BETWEEN #{startTime} and #{endTime} group by a.aid)y on x.aid=y.aid
  1184. </select>
  1185. <select id="financeCountRangeReceivables" resultType="java.math.BigDecimal">
  1186. SELECT ifnull(sum(a.money),0) receivables
  1187. from new_order_dun a left join t_order_new b on a.order_no =b.order_no
  1188. left join department c on b.order_dep =c.id
  1189. where a.status =1 and b.delete_sign in (0,2,3)
  1190. and c.finance_id = #{aid}
  1191. and a.start_time between #{startTime} and #{endTime}
  1192. </select>
  1193. <select id="selectFinanceChangeCount" resultType="com.goafanti.admin.bo.OutFinanceCount">
  1194. select c.finance_id aid,sum(if(a.process_state=6,1,0))changeCount,
  1195. sum(if(a.process_state>6 and a.status=2,1,0)) changeInvoiceCount
  1196. from new_order_change a left join t_order_new b on a.order_no =b.order_no
  1197. left join department c on b.order_dep =c.id
  1198. where a.process_state in (6,8,9) and a.status in(1,2) and b.delete_sign in (0,2,3)
  1199. and c.finance_id = #{aid}
  1200. </select>
  1201. <select id="selectFinanceReceivablesCount" resultType="java.math.BigDecimal">
  1202. SELECT sum(a.money) receivables
  1203. from new_order_dun a left join t_order_new b on a.order_no =b.order_no
  1204. left join department c on b.order_dep =c.id
  1205. where a.status =1 and b.delete_sign in (0,2,3)
  1206. and c.finance_id = #{aid}
  1207. and a.start_time between #{startTime} and #{endTime}
  1208. </select>
  1209. <select id="selectExpenseFinanceByAid" resultType="com.goafanti.common.model.Admin">
  1210. select c.id,c.name,c.open_id openId,c.email
  1211. from admin a left join department b on a.department_id=b.id
  1212. left join admin c on b.finance_id=c.id
  1213. where a.id= #{aid}
  1214. </select>
  1215. <update id="updateDepExpenseFinance">
  1216. update expense_account a left join expense_account_examine b on a.id=b.eaid
  1217. left join admin c on c.id= #{expenseFinanceId}
  1218. set b.auditor =c.id ,b.auditorName =c.name
  1219. where a.process_status in (0,1,2,3) and a.status =1 and b.process_status =3 and b.status =0
  1220. and a.apply_dep = #{id}
  1221. </update>
  1222. <select id="agentList" resultMap="AdminMap">
  1223. select
  1224. <include refid="AdminAllSql"/>
  1225. from admin
  1226. where status='0' and call_no>0
  1227. </select>
  1228. <select id="selectByCallStaffNo" resultMap="AdminMap">
  1229. select
  1230. <include refid="AdminAllSql"/>
  1231. from admin
  1232. where call_no = #{callStaffNo}
  1233. </select>
  1234. <select id="queryByTeamId" resultMap="AdminMap">
  1235. select
  1236. <include refid="AdminAllSql"/>
  1237. from admin
  1238. where team_id = #{teamId}
  1239. </select>
  1240. <select id="selectUserCount" resultType="com.goafanti.admin.bo.AdminStatisticsBo">
  1241. select aid,sum(if( share_type=0 and channel=0 and new_channel=0,1,0))privateSum,
  1242. sum(if(share_type=0 and new_channel=1,1,0))channelSum,
  1243. sum(if( share_type=2 ,1,0))signSum
  1244. from `user` where `type` =1 and source in(1,2,3)
  1245. AND aid = #{aid}
  1246. group by aid
  1247. </select>
  1248. </mapper>