AdminMapper.xml 62 KB

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