AdminMapper.xml 65 KB

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