UserMapperExt.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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.UserMapper">
  4. <select id="selectCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  5. <choose>
  6. <when test="type == 0">
  7. select
  8. a.id as uid,a.type,a.status, date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,a.service_certification as serviceCertification,
  9. a.user_certification as userCertification,a.current_member_status as currentMemberStatus,a.identify_name as name,a.lvl,
  10. b.contacts,b.contact_mobile as contactMobile,b.international,b.expert,b.celebrity,
  11. dg1.name as province,dg2.name as city, dg3.name as area,c.name as industry
  12. from
  13. (select
  14. id,type,status,create_time,service_certification,user_certification,current_member_status,identify_name,lvl
  15. from user
  16. where type = 0
  17. <if test="aid != null and aid !=''">
  18. and aid = #{aid,jdbcType=VARCHAR}
  19. </if>
  20. <if test="shareType != null">
  21. and share_type = #{shareType,jdbcType=VARCHAR}
  22. </if>
  23. <if test="status != null">
  24. and status = #{status,jdbcType=INTEGER}
  25. </if>
  26. <if test="serviceCertification != null">
  27. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  28. </if>
  29. <if test="userCertification != null">
  30. and user_certification = #{userCertification,jdbcType=INTEGER}
  31. </if>
  32. <if test="currentMemberStatus != null">
  33. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  34. </if>
  35. <if test="startDate != null and startDate != ''">
  36. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  37. </if>
  38. <if test="endDate != null and endDate != ''">
  39. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  40. </if>
  41. )as a inner join user_identity b on a.id = b.uid
  42. left join district_glossory dg1 on b.province = dg1.id
  43. left join district_glossory dg2 on b.city = dg2.id
  44. left join district_glossory dg3 on b.area = dg3.id
  45. left join industry_category c on b.industry = c.id
  46. where 1=1
  47. <if test="name != null and name !=''">
  48. and b.username = #{name,jdbcType=VARCHAR}
  49. </if>
  50. <if test="province != null">
  51. and b.province = #{province,jdbcType=INTEGER}
  52. </if>
  53. <if test="city != null">
  54. and b.city = #{province,city=INTEGER}
  55. </if>
  56. <if test="province != null">
  57. and b.area = #{area,jdbcType=INTEGER}
  58. </if>
  59. <if test="industry != null">
  60. and b.industry = #{industry,jdbcType=INTEGER}
  61. </if>
  62. </when>
  63. <when test="type == 1">
  64. select
  65. a.id as uid,a.type,a.status, date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,a.service_certification as serviceCertification,
  66. a.user_certification as userCertification,a.current_member_status as currentMemberStatus,a.identify_name as name,a.lvl,
  67. b.contacts,b.contact_mobile as contactMobile,b.international,0 as expert,0 as celebrity,
  68. dg1.name as province,dg2.name as city, dg3.name as area,c.name as industry
  69. from
  70. (select
  71. id,type,status,create_time,service_certification,user_certification,current_member_status,identify_name,lvl
  72. from user
  73. where type = 1
  74. <if test="aid != null and aid !=''">
  75. and aid = #{aid,jdbcType=VARCHAR}
  76. </if>
  77. <if test="shareType != null">
  78. and share_type = #{shareType,jdbcType=VARCHAR}
  79. </if>
  80. <if test="status != null">
  81. and status = #{status,jdbcType=INTEGER}
  82. </if>
  83. <if test="serviceCertification != null">
  84. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  85. </if>
  86. <if test="userCertification != null">
  87. and user_certification = #{userCertification,jdbcType=INTEGER}
  88. </if>
  89. <if test="currentMemberStatus != null">
  90. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  91. </if>
  92. <if test="startDate != null and startDate != ''">
  93. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  94. </if>
  95. <if test="endDate != null and endDate != ''">
  96. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  97. </if>
  98. )as a inner join organization_identity b on a.id = b.uid
  99. left join district_glossory dg1 on b.licence_province = dg1.id
  100. left join district_glossory dg2 on b.licence_city = dg2.id
  101. left join district_glossory dg3 on b.licence_area = dg3.id
  102. left join industry_category c on b.industry = c.id
  103. where 1=1
  104. <if test="name != null and name != ''">
  105. and b.unit_name = #{name,jdbcType=VARCHAR}
  106. </if>
  107. <if test="province != null">
  108. and b.licence_province = #{province,jdbcType=INTEGER}
  109. </if>
  110. <if test="city != null">
  111. and b.licence_city = #{province,city=INTEGER}
  112. </if>
  113. <if test="province != null">
  114. and b.licence_area = #{area,jdbcType=INTEGER}
  115. </if>
  116. <if test="industry != null">
  117. and b.industry = #{industry,jdbcType=INTEGER}
  118. </if>
  119. </when>
  120. <otherwise>
  121. select * from (
  122. select
  123. a.id as uid,a.type,a.status, date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,a.service_certification as serviceCertification,
  124. a.user_certification as userCertification,a.current_member_status as currentMemberStatus,a.identify_name as name,a.lvl,
  125. b.contacts,b.contact_mobile as contactMobile,b.international,b.expert,b.celebrity,
  126. dg1.name as province,dg2.name as city, dg3.name as area,c.name as industry
  127. from
  128. (select
  129. id,type,status,create_time,service_certification,user_certification,current_member_status,identify_name,lvl
  130. from user
  131. where type = 0
  132. <if test="aid != null and aid !=''">
  133. and aid = #{aid,jdbcType=VARCHAR}
  134. </if>
  135. <if test="shareType != null">
  136. and share_type = #{shareType,jdbcType=VARCHAR}
  137. </if>
  138. <if test="status != null">
  139. and status = #{status,jdbcType=INTEGER}
  140. </if>
  141. <if test="serviceCertification != null">
  142. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  143. </if>
  144. <if test="userCertification != null">
  145. and user_certification = #{userCertification,jdbcType=INTEGER}
  146. </if>
  147. <if test="currentMemberStatus != null">
  148. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  149. </if>
  150. <if test="startDate != null and startDate != ''">
  151. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  152. </if>
  153. <if test="endDate != null and endDate != ''">
  154. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  155. </if>
  156. )as a inner join user_identity b on a.id = b.uid
  157. left join district_glossory dg1 on b.province = dg1.id
  158. left join district_glossory dg2 on b.city = dg2.id
  159. left join district_glossory dg3 on b.area = dg3.id
  160. left join industry_category c on b.industry = c.id
  161. where 1=1
  162. <if test="name != null and name != ''">
  163. and b.username = #{name,jdbcType=VARCHAR}
  164. </if>
  165. <if test="province != null">
  166. and b.province = #{province,jdbcType=INTEGER}
  167. </if>
  168. <if test="city != null">
  169. and b.city = #{province,city=INTEGER}
  170. </if>
  171. <if test="province != null">
  172. and b.area = #{area,jdbcType=INTEGER}
  173. </if>
  174. <if test="industry != null">
  175. and b.industry = #{industry,jdbcType=INTEGER}
  176. </if>
  177. union
  178. select
  179. a.id as uid,a.type,a.status, date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,a.service_certification as serviceCertification,
  180. a.user_certification as userCertification,a.current_member_status as currentMemberStatus,a.identify_name as name,a.lvl,
  181. b.contacts,b.contact_mobile as contactMobile,b.international,0 as expert,0 as celebrity,
  182. dg1.name as province,dg2.name as city, dg3.name as area,c.name as industry
  183. from
  184. (select
  185. id,type,status,create_time,service_certification,user_certification,current_member_status,identify_name,lvl
  186. from user
  187. where type = 1
  188. <if test="aid != null and aid !=''">
  189. and aid = #{aid,jdbcType=VARCHAR}
  190. </if>
  191. <if test="shareType != null">
  192. and share_type = #{shareType,jdbcType=VARCHAR}
  193. </if>
  194. <if test="status != null">
  195. and status = #{status,jdbcType=INTEGER}
  196. </if>
  197. <if test="serviceCertification != null">
  198. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  199. </if>
  200. <if test="userCertification != null">
  201. and user_certification = #{userCertification,jdbcType=INTEGER}
  202. </if>
  203. <if test="currentMemberStatus != null">
  204. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  205. </if>
  206. <if test="startDate != null and startDate != ''">
  207. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  208. </if>
  209. <if test="endDate != null and endDate != ''">
  210. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  211. </if>
  212. )as a inner join organization_identity b on a.id = b.uid
  213. left join district_glossory dg1 on b.licence_province = dg1.id
  214. left join district_glossory dg2 on b.licence_city = dg2.id
  215. left join district_glossory dg3 on b.licence_area = dg3.id
  216. left join industry_category c on b.industry = c.id
  217. where 1=1
  218. <if test="name != null and name != ''">
  219. and b.unit_name = #{name,jdbcType=VARCHAR}
  220. </if>
  221. <if test="province != null">
  222. and b.licence_province = #{province,jdbcType=INTEGER}
  223. </if>
  224. <if test="city != null">
  225. and b.licence_city = #{province,city=INTEGER}
  226. </if>
  227. <if test="province != null">
  228. and b.licence_area = #{area,jdbcType=INTEGER}
  229. </if>
  230. <if test="industry != null">
  231. and b.industry = #{industry,jdbcType=INTEGER}
  232. </if>
  233. )y
  234. </otherwise>
  235. </choose>
  236. order by createTime desc
  237. <if test="page_sql!=null">
  238. ${page_sql}
  239. </if>
  240. </select>
  241. <select id="selectCustomerCount" resultType="java.lang.Integer">
  242. <choose>
  243. <when test="type == 0">
  244. select
  245. count(0)
  246. from
  247. (select
  248. id
  249. from user
  250. where type = 0
  251. <if test="aid != null and aid !=''">
  252. and aid = #{aid,jdbcType=VARCHAR}
  253. </if>
  254. <if test="shareType != null">
  255. and share_type = #{shareType,jdbcType=VARCHAR}
  256. </if>
  257. <if test="status != null">
  258. and status = #{status,jdbcType=INTEGER}
  259. </if>
  260. <if test="serviceCertification != null">
  261. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  262. </if>
  263. <if test="userCertification != null">
  264. and user_certification = #{userCertification,jdbcType=INTEGER}
  265. </if>
  266. <if test="currentMemberStatus != null">
  267. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  268. </if>
  269. <if test="startDate != null and startDate != ''">
  270. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  271. </if>
  272. <if test="endDate != null and endDate != ''">
  273. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  274. </if>
  275. )as a inner join user_identity b on a.id = b.uid
  276. where 1=1
  277. <if test="name != null and name !=''">
  278. and b.username = #{name,jdbcType=VARCHAR}
  279. </if>
  280. <if test="province != null">
  281. and b.province = #{province,jdbcType=INTEGER}
  282. </if>
  283. <if test="city != null">
  284. and b.city = #{province,city=INTEGER}
  285. </if>
  286. <if test="province != null">
  287. and b.area = #{area,jdbcType=INTEGER}
  288. </if>
  289. <if test="industry != null">
  290. and b.industry = #{industry,jdbcType=INTEGER}
  291. </if>
  292. </when>
  293. <when test="type == 1">
  294. select
  295. count(0)
  296. from
  297. (select
  298. id
  299. from user
  300. where type = 1
  301. <if test="aid != null and aid !=''">
  302. and aid = #{aid,jdbcType=VARCHAR}
  303. </if>
  304. <if test="shareType != null">
  305. and share_type = #{shareType,jdbcType=VARCHAR}
  306. </if>
  307. <if test="status != null">
  308. and status = #{status,jdbcType=INTEGER}
  309. </if>
  310. <if test="serviceCertification != null">
  311. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  312. </if>
  313. <if test="userCertification != null">
  314. and user_certification = #{userCertification,jdbcType=INTEGER}
  315. </if>
  316. <if test="currentMemberStatus != null">
  317. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  318. </if>
  319. <if test="startDate != null and startDate != ''">
  320. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  321. </if>
  322. <if test="endDate != null and endDate != ''">
  323. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  324. </if>
  325. )as a inner join organization_identity b on a.id = b.uid
  326. where 1=1
  327. <if test="name != null and name !=''">
  328. and b.unit_name = #{name,jdbcType=VARCHAR}
  329. </if>
  330. <if test="province != null">
  331. and b.licence_province = #{province,jdbcType=INTEGER}
  332. </if>
  333. <if test="city != null">
  334. and b.licence_city = #{province,city=INTEGER}
  335. </if>
  336. <if test="province != null">
  337. and b.licence_area = #{area,jdbcType=INTEGER}
  338. </if>
  339. <if test="industry != null">
  340. and b.industry = #{industry,jdbcType=INTEGER}
  341. </if>
  342. </when>
  343. <otherwise>
  344. select count(0)
  345. from(
  346. select
  347. a.id
  348. from
  349. (select
  350. id
  351. from user
  352. where type = 0
  353. <if test="aid != null and aid !=''">
  354. and aid = #{aid,jdbcType=VARCHAR}
  355. </if>
  356. <if test="shareType != null">
  357. and share_type = #{shareType,jdbcType=VARCHAR}
  358. </if>
  359. <if test="status != null">
  360. and status = #{status,jdbcType=INTEGER}
  361. </if>
  362. <if test="serviceCertification != null">
  363. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  364. </if>
  365. <if test="userCertification != null">
  366. and user_certification = #{userCertification,jdbcType=INTEGER}
  367. </if>
  368. <if test="currentMemberStatus != null">
  369. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  370. </if>
  371. <if test="startDate != null and startDate != ''">
  372. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  373. </if>
  374. <if test="endDate != null and endDate != ''">
  375. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  376. </if>
  377. )as a inner join user_identity b on a.id = b.uid
  378. where 1=1
  379. <if test="name != null and name !=''">
  380. and b.username = #{name,jdbcType=VARCHAR}
  381. </if>
  382. <if test="province != null">
  383. and b.province = #{province,jdbcType=INTEGER}
  384. </if>
  385. <if test="city != null">
  386. and b.city = #{province,city=INTEGER}
  387. </if>
  388. <if test="province != null">
  389. and b.area = #{area,jdbcType=INTEGER}
  390. </if>
  391. <if test="industry != null">
  392. and b.industry = #{industry,jdbcType=INTEGER}
  393. </if>
  394. union
  395. select
  396. a.id
  397. from
  398. (select
  399. id
  400. from user
  401. where type = 1
  402. <if test="aid != null and aid !=''">
  403. and aid = #{aid,jdbcType=VARCHAR}
  404. </if>
  405. <if test="shareType != null">
  406. and share_type = #{shareType,jdbcType=VARCHAR}
  407. </if>
  408. <if test="status != null">
  409. and status = #{status,jdbcType=INTEGER}
  410. </if>
  411. <if test="serviceCertification != null">
  412. and service_certification = #{serviceCertification,jdbcType=INTEGER}
  413. </if>
  414. <if test="userCertification != null">
  415. and user_certification = #{userCertification,jdbcType=INTEGER}
  416. </if>
  417. <if test="currentMemberStatus != null">
  418. and current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  419. </if>
  420. <if test="startDate != null and startDate != ''">
  421. and create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  422. </if>
  423. <if test="endDate != null and endDate != ''">
  424. and create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  425. </if>
  426. )as a inner join organization_identity b on a.id = b.uid
  427. where 1=1
  428. <if test="name != null and name !=''">
  429. and b.unit_name = #{name,jdbcType=VARCHAR}
  430. </if>
  431. <if test="province != null">
  432. and b.licence_province = #{province,jdbcType=INTEGER}
  433. </if>
  434. <if test="city != null">
  435. and b.licence_city = #{province,city=INTEGER}
  436. </if>
  437. <if test="province != null">
  438. and b.licence_area = #{area,jdbcType=INTEGER}
  439. </if>
  440. <if test="industry != null">
  441. and b.industry = #{industry,jdbcType=INTEGER}
  442. </if>
  443. ) x
  444. </otherwise>
  445. </choose>
  446. </select>
  447. </mapper>