AdminMapper.xml 55 KB

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