UserMapperExt.xml 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  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="selectPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  5. select
  6. a.id as uid,
  7. a.type,
  8. a.status,
  9. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  10. a.business_audit as businessAudit,
  11. a.current_member_status as currentMemberStatus,
  12. a.identify_name as name,
  13. a.lvl,a.is_member as isMember,
  14. a.society_tag as societyTag,
  15. a.share_type as shareType,
  16. b.contacts,
  17. b.contact_mobile as contactMobile,
  18. b.international,
  19. b.expert,
  20. b.audit_status as auditStatus,
  21. dg1.name as province,
  22. dg2.name as city,
  23. dg3.name as area,
  24. c.name as industry,
  25. d.name as adminName,
  26. b.expert_audit as expertAudit
  27. from user a inner join user_identity b on a.id = b.uid
  28. left join district_glossory dg1 on b.province = dg1.id
  29. left join district_glossory dg2 on b.city = dg2.id
  30. left join district_glossory dg3 on b.area = dg3.id
  31. left join industry_category c on b.industry = c.id
  32. left join admin d on a.aid = d.id
  33. where a.type = 0 and a.status != 1
  34. <if test="aid != null and aid !=''">
  35. and a.aid = #{aid,jdbcType=VARCHAR}
  36. </if>
  37. <if test="expertAudit != null and expertAudit !=''">
  38. and b.expert_audit = #{expertAudit,jdbcType=VARCHAR}
  39. </if>
  40. <if test="name != null and name != ''">
  41. and a.identify_name like concat('%',#{name},'%')
  42. </if>
  43. <if test="shareType != null">
  44. and a.share_type = #{shareType,jdbcType=VARCHAR}
  45. </if>
  46. <if test="status != null">
  47. and a.status = #{status,jdbcType=INTEGER}
  48. </if>
  49. <if test="businessAudit != null">
  50. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  51. </if>
  52. <if test="isMember != null">
  53. and a.is_member = #{isMember,jdbcType=INTEGER}
  54. </if>
  55. <if test="lvl != null">
  56. and a.lvl = #{lvl,jdbcType=INTEGER}
  57. </if>
  58. <if test="currentMemberStatus != null">
  59. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  60. </if>
  61. <if test="societyTag != null and societyTag != ''">
  62. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  63. </if>
  64. <if test="startDate != null and startDate != ''">
  65. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  66. </if>
  67. <if test="endDate != null and endDate != ''">
  68. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  69. </if>
  70. <if test="province != null">
  71. and b.province = #{province,jdbcType=INTEGER}
  72. </if>
  73. <if test="city != null">
  74. and b.city = #{city,jdbcType=INTEGER}
  75. </if>
  76. <if test="area != null">
  77. and b.area = #{area,jdbcType=INTEGER}
  78. </if>
  79. <if test="industry != null">
  80. and b.industry = #{industry,jdbcType=INTEGER}
  81. </if>
  82. <if test="expert != null">
  83. and b.expert = #{expert,jdbcType=INTEGER}
  84. </if>
  85. <if test="international != null">
  86. and b.international = #{international,jdbcType=INTEGER}
  87. </if>
  88. <if test="auditStatus != null">
  89. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  90. </if>
  91. order by a.create_time desc
  92. <if test="page_sql != null">
  93. ${page_sql}
  94. </if>
  95. </select>
  96. <select id="selectPersonalCustomerCount" resultType="java.lang.Integer">
  97. select count(0)
  98. from user a inner join user_identity b on a.id = b.uid
  99. left join district_glossory dg1 on b.province = dg1.id
  100. left join district_glossory dg2 on b.city = dg2.id
  101. left join district_glossory dg3 on b.area = dg3.id
  102. left join industry_category c on b.industry = c.id
  103. left join admin d on a.aid = d.id
  104. where a.type = 0 and a.status != 1 and a.audit_status = 1
  105. <if test="aid != null and aid !=''">
  106. and a.aid = #{aid,jdbcType=VARCHAR}
  107. </if>
  108. <if test="name != null and name != ''">
  109. and a.identify_name like concat('%',#{name},'%')
  110. </if>
  111. <if test="expertAudit != null and expertAudit !=''">
  112. and b.expert_audit = #{expertAudit,jdbcType=VARCHAR}
  113. </if>
  114. <if test="shareType != null">
  115. and a.share_type = #{shareType,jdbcType=VARCHAR}
  116. </if>
  117. <if test="status != null">
  118. and a.status = #{status,jdbcType=INTEGER}
  119. </if>
  120. <if test="businessAudit != null">
  121. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  122. </if>
  123. <if test="isMember != null">
  124. and a.is_member = #{isMember,jdbcType=INTEGER}
  125. </if>
  126. <if test="lvl != null">
  127. and a.lvl = #{lvl,jdbcType=INTEGER}
  128. </if>
  129. <if test="currentMemberStatus != null">
  130. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  131. </if>
  132. <if test="societyTag != null and societyTag != ''">
  133. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  134. </if>
  135. <if test="startDate != null and startDate != ''">
  136. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  137. </if>
  138. <if test="endDate != null and endDate != ''">
  139. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  140. </if>
  141. <if test="province != null">
  142. and b.province = #{province,jdbcType=INTEGER}
  143. </if>
  144. <if test="city != null">
  145. and b.city = #{city,jdbcType=INTEGER}
  146. </if>
  147. <if test="area != null">
  148. and b.area = #{area,jdbcType=INTEGER}
  149. </if>
  150. <if test="industry != null">
  151. and b.industry = #{industry,jdbcType=INTEGER}
  152. </if>
  153. <if test="expert != null">
  154. and b.expert = #{expert,jdbcType=INTEGER}
  155. </if>
  156. <if test="international != null">
  157. and b.international = #{international,jdbcType=INTEGER}
  158. </if>
  159. <if test="auditStatus != null">
  160. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  161. </if>
  162. </select>
  163. <select id="selectOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  164. select
  165. a.id as uid,
  166. a.type,
  167. a.status,
  168. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  169. a.business_audit as businessAudit,
  170. a.current_member_status as currentMemberStatus,
  171. a.identify_name as name,
  172. a.lvl,
  173. a.is_member as isMember,
  174. a.society_tag as societyTag,
  175. share_type as shareType,
  176. b.contacts,
  177. b.contact_mobile as contactMobile,
  178. b.international,
  179. b.listed,
  180. b.high_tech_zone as highTechZone,
  181. b.audit_status as auditStatus,
  182. dg1.name as province,
  183. dg2.name as city,
  184. dg3.name as area,
  185. c.name as industry,
  186. d.name as adminName
  187. from user a inner join organization_identity b on a.id = b.uid
  188. left join district_glossory dg1 on b.location_province = dg1.id
  189. left join district_glossory dg2 on b.location_city = dg2.id
  190. left join district_glossory dg3 on b.location_area = dg3.id
  191. left join industry_category c on b.industry = c.id
  192. left join admin d on a.aid = d.id
  193. where a.type = 1 and a.status != 1 and a.audit_status = 1
  194. <if test="aid != null and aid !=''">
  195. and a.aid = #{aid,jdbcType=VARCHAR}
  196. </if>
  197. <if test="name != null and name != ''">
  198. and a.identify_name like concat('%',#{name},'%')
  199. </if>
  200. <if test="shareType != null">
  201. and a.share_type = #{shareType,jdbcType=VARCHAR}
  202. </if>
  203. <if test="status != null">
  204. and a.status = #{status,jdbcType=INTEGER}
  205. </if>
  206. <if test="businessAudit != null">
  207. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  208. </if>
  209. <if test="isMember != null">
  210. and a.is_member = #{isMember,jdbcType=INTEGER}
  211. </if>
  212. <if test="currentMemberStatus != null">
  213. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  214. </if>
  215. <if test="lvl != null">
  216. and a.lvl = #{lvl,jdbcType=INTEGER}
  217. </if>
  218. <if test="societyTag != null and societyTag != ''">
  219. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  220. </if>
  221. <if test="startDate != null and startDate != ''">
  222. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  223. </if>
  224. <if test="endDate != null and endDate != ''">
  225. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  226. </if>
  227. <if test="province != null">
  228. and b.location_province = #{province,jdbcType=INTEGER}
  229. </if>
  230. <if test="city != null">
  231. and b.location_city = #{city,jdbcType=INTEGER}
  232. </if>
  233. <if test="area != null">
  234. and b.location_area = #{area,jdbcType=INTEGER}
  235. </if>
  236. <if test="industry != null">
  237. and b.industry = #{industry,jdbcType=INTEGER}
  238. </if>
  239. <if test="listed != null">
  240. and b.listed = #{listed,jdbcType=INTEGER}
  241. </if>
  242. <if test="highTechZone != null">
  243. and b.high_tech_zone = #{highTechZone,jdbcType=INTEGER}
  244. </if>
  245. <if test="international != null">
  246. and b.international = #{international,jdbcType=INTEGER}
  247. </if>
  248. <if test="auditStatus != null">
  249. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  250. </if>
  251. order by a.create_time desc
  252. <if test="page_sql != null">
  253. ${page_sql}
  254. </if>
  255. </select>
  256. <select id="selectOrganizationCustomerCount" resultType="java.lang.Integer">
  257. select
  258. count(0)
  259. from user a inner join organization_identity b on a.id = b.uid
  260. where a.type = 1 and a.status != 1 and a.audit_status = 1
  261. <if test="aid != null and aid !=''">
  262. and a.aid = #{aid,jdbcType=VARCHAR}
  263. </if>
  264. <if test="name != null and name != ''">
  265. and a.identify_name like concat('%',#{name},'%')
  266. </if>
  267. <if test="shareType != null">
  268. and a.share_type = #{shareType,jdbcType=VARCHAR}
  269. </if>
  270. <if test="status != null">
  271. and a.status = #{status,jdbcType=INTEGER}
  272. </if>
  273. <if test="businessAudit != null">
  274. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  275. </if>
  276. <if test="currentMemberStatus != null">
  277. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  278. </if>
  279. <if test="isMember != null">
  280. and a.is_member = #{isMember,jdbcType=INTEGER}
  281. </if>
  282. <if test="societyTag != null and societyTag != ''">
  283. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  284. </if>
  285. <if test="startDate != null and startDate != ''">
  286. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  287. </if>
  288. <if test="endDate != null and endDate != ''">
  289. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  290. </if>
  291. <if test="province != null">
  292. and b.location_province = #{province,jdbcType=INTEGER}
  293. </if>
  294. <if test="city != null">
  295. and b.location_city = #{city,jdbcType=INTEGER}
  296. </if>
  297. <if test="area != null">
  298. and b.location_area = #{area,jdbcType=INTEGER}
  299. </if>
  300. <if test="industry != null">
  301. and b.industry = #{industry,jdbcType=INTEGER}
  302. </if>
  303. <if test="listed != null">
  304. and b.listed = #{listed,jdbcType=INTEGER}
  305. </if>
  306. <if test="highTechZone != null">
  307. and b.high_tech_zone = #{highTechZone,jdbcType=INTEGER}
  308. </if>
  309. <if test="international != null">
  310. and b.international = #{international,jdbcType=INTEGER}
  311. </if>
  312. <if test="auditStatus != null">
  313. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  314. </if>
  315. </select>
  316. <select id="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  317. select id,identify_name as name from user where identify_name like
  318. concat('%',#{identifyName},'%') and status <![CDATA[!= ]]> 1 and audit_status = 1
  319. </select>
  320. <select id="judgeCustomerByName" resultType="java.lang.Integer">
  321. select count(0) from user where identify_name = #{identifyName,jdbcType=VARCHAR}
  322. and status <![CDATA[!= ]]> 1
  323. </select>
  324. <select id="findOrganizationCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOrganizationDetailBo">
  325. select
  326. a.id as uid,
  327. a.society_tag as societyTag,
  328. a.company_logo_url as companyLogoUrl,
  329. a.introduction,
  330. a.identify_name as identifyName,
  331. a.business_audit as businessAudit,
  332. b.industry,
  333. b.location_province as locationProvince,
  334. b.location_city as locationCity,
  335. b.location_area as locationArea,
  336. b.postal_address as postalAddress,
  337. b.contacts_fixed_tel as contactsFixedTel,
  338. b.contacts_fax as contactsFax,
  339. b.registered_capital registeredCapital,
  340. b.enterprise_scale as enterpriseScale,
  341. b.legal_person as legalPerson,
  342. b.legal_person_id_card as legalPersonIdCard,
  343. b.legal_person_tel as legalPersonTel,
  344. b.legal_person_email as legalPersonEmail,
  345. b.high_tech_zone highTechZone,
  346. b.listed,
  347. b.international,
  348. b.org_code as orgCode,
  349. b.org_code_url as orgCodeUrl,
  350. b.business_scope as businessScope,
  351. b.id,
  352. b.contacts,
  353. b.contact_mobile as contactMobile,
  354. b.audit_status as auditStatus,
  355. b.licence_number as licenceNumber,
  356. a.aid as aid,d.name as adminName
  357. from
  358. user a inner join organization_identity b on a.id = b.uid
  359. left join admin d on d.id = a.aid
  360. where
  361. a.id = #{uid,jdbcType=VARCHAR}
  362. </select>
  363. <select id="findPersonalCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerPersonalDetailBo">
  364. select
  365. a.id as uid,
  366. a.identify_name as identifyName,
  367. a.society_tag as societyTag,
  368. a.head_portrait_url as headPortraitUrl,
  369. a.introduction,
  370. a.business_audit as businessAudit,
  371. b.id,
  372. b.industry,
  373. b.sex,
  374. b.date_of_birth_year as dateOfBirthYear,
  375. b.date_of_birth_month as dateOfBirthMonth,
  376. b.id_number as idNumber,
  377. b.province,
  378. b.city,
  379. b.area,
  380. b.positive_id_url as positiveIdUrl,
  381. b.opposite_id_url as oppositeIdUrl,
  382. b.postal_address as postalAddress,
  383. b.contact_mobile as contactMobile,
  384. b.fixed_tel as fixedTel,
  385. b.email,
  386. b.expert,
  387. b.international,
  388. b.contacts,
  389. b.contact_mobile as contactMobile,
  390. b.qq,
  391. b.professional_title as professionalTitle,
  392. b.work_unit as workUnit,
  393. b.education,
  394. b.major_category as majorCategory,
  395. b.qualification,
  396. b.audit_status as auditStatus,
  397. b.graduate_school as graduateSchool,
  398. b.consultation_price as consultationPrice,
  399. b.expert_audit as expertAudit,
  400. b.release_status as releaseStatus,
  401. a.aid as aid,d.name as adminName
  402. from
  403. user a inner join user_identity b on
  404. a.id = b.uid
  405. left join admin d on d.id = a.aid
  406. where
  407. a.id = #{uid,jdbcType=VARCHAR}
  408. </select>
  409. <select id="selectFollowHistoryList" resultType="com.goafanti.customer.bo.FollowListBo">
  410. select
  411. a.id as followId,
  412. a.create_time as followTime,
  413. a.contact_type as contactType,
  414. a.result,
  415. b.identify_name as identifyName,
  416. c.name as contacts,
  417. c.mobile as contactMobile,
  418. d.name as adminName
  419. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  420. ,e.id as ufbId,e.follow_situation as followSituation,e.customer_status as customerStatus
  421. </if>
  422. from user_follow a
  423. left join user b on a.uid = b.id
  424. left join organization_contact_book c on a.ocb_id = c.id
  425. left join admin d on a.aid = d.id
  426. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  427. inner join user_follow_business e on a.id = e.follow_id
  428. </if>
  429. where a.effective = 0
  430. <if test="uid != null and uid != ''">
  431. and a.uid = #{uid,jdbcType=VARCHAR}
  432. </if>
  433. <if test="aid != null and aid != ''">
  434. and a.aid = #{aid,jdbcType=VARCHAR}
  435. </if>
  436. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  437. and e.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  438. </if>
  439. <if test="page_sql != null">
  440. ${page_sql}
  441. </if>
  442. </select>
  443. <select id="selectFollowHistoryCount" resultType="java.lang.Integer">
  444. select
  445. count(0)
  446. from user_follow a
  447. left join user b on a.uid = b.id
  448. left join organization_contact_book c on a.ocb_id = c.id
  449. left join admin d on a.aid = d.id
  450. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  451. inner join user_follow_business e on a.id = e.follow_id
  452. </if>
  453. where a.effective = 0
  454. <if test="uid != null and uid != ''">
  455. and a.uid = #{uid,jdbcType=VARCHAR}
  456. </if>
  457. <if test="aid != null and aid != ''">
  458. and a.aid = #{aid,jdbcType=VARCHAR}
  459. </if>
  460. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  461. and e.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  462. </if>
  463. </select>
  464. <select id="findUserAccountDetail" parameterType="java.lang.String" resultType="com.goafanti.common.model.User">
  465. select
  466. id,
  467. mobile,
  468. nickname,
  469. create_time as createTime,
  470. type,
  471. source,
  472. email,
  473. is_member as isMember,
  474. lvl,
  475. current_member_status currentMemberStatus,
  476. business_audit as businessAudit,
  477. identify_name as identifyName,
  478. status
  479. from
  480. user
  481. where id = #{uid,jdbcType=VARCHAR}
  482. </select>
  483. <select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  484. select id,name,mobile,email,qq,wechat,depatrment,position,major from organization_contact_book
  485. where uid = #{uid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR}
  486. </select>
  487. <select id="findAllContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  488. select id,name,mobile,major,sex,depatrment,wechat,qq from organization_contact_book
  489. where uid = #{uid,jdbcType=VARCHAR}
  490. </select>
  491. <select id="findFollowById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.FollowBusinessBo">
  492. select
  493. a.id as followId,
  494. a.uid,
  495. a.ocb_id as ocbId,
  496. a.contact_type as contactType,
  497. a.result,
  498. a.create_time as followTime,
  499. b.identify_name as identifyName,
  500. c.name as contacts,
  501. c.mobile as contactType,
  502. d.name as adminName
  503. from
  504. user_follow a
  505. left join user b on a.uid = b.id
  506. left join organization_contact_book c on a.ocb_id = c.id
  507. left join admin d on a.aid = d.id
  508. where a.id = #{followId,jdbcType=VARCHAR}
  509. </select>
  510. <select id="customerStatisticsList" resultType="com.goafanti.customer.bo.StatisticBo">
  511. select a.*,b.name as adminName,c.name as departmentName from (
  512. select
  513. aid,
  514. sum(case when customer_status = 0 then 1 else 0 end) as newNo, <!-- 新客户 -->
  515. sum(case when customer_status = 1 then 1 else 0 end) as intentionNo, <!-- 意向客户 -->
  516. sum(case when customer_status = 2 then 1 else 0 end) as pointNo, <!-- 重点客户 -->
  517. sum(case when customer_status = 3 then 1 else 0 end) as interviewNo, <!-- 面谈客户 -->
  518. sum(case when customer_status = 4 then 1 else 0 end) as signNo, <!-- 签单客户 -->
  519. sum(case when customer_status = 5 then 1 else 0 end) as refuseNo, <!-- 拒绝客户 -->
  520. sum(case when customer_status = 6 then 1 else 0 end) as stopNo <!-- 停止跟进 -->
  521. from user_business where 1=1
  522. <if test="sDate != null">
  523. and create_time &gt; #{sDate,jdbcType=DATE}
  524. </if>
  525. <if test="eDate != null">
  526. and create_time &lt; #{eDate,jdbcType=DATE}
  527. </if>
  528. <if test="businessGlossoryId != null">
  529. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  530. </if>
  531. group by aid
  532. )a
  533. left join admin b on a.aid = b.id
  534. left join department_management c on b.department_id = c.id
  535. <if test="depNo != null">
  536. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  537. </if>
  538. <if test="page_sql != null">
  539. ${page_sql}
  540. </if>
  541. </select>
  542. <select id="customerStatisticsCount" resultType="java.lang.Integer">
  543. select count(0) from (
  544. select
  545. aid
  546. from user_business where 1=1
  547. <if test="sDate != null">
  548. and create_time &gt; #{sDate,jdbcType=DATE}
  549. </if>
  550. <if test="eDate != null">
  551. and create_time &lt; #{eDate,jdbcType=DATE}
  552. </if>
  553. <if test="businessGlossoryId != null">
  554. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  555. </if>
  556. group by aid
  557. )a
  558. left join admin b on a.aid = b.id
  559. left join department_management c on b.department_id = c.id
  560. <if test="depNo !=null">
  561. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  562. </if>
  563. </select>
  564. <select id="businessStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  565. select a.*,b.name as adminName,c.name as departmentName from (
  566. select
  567. aid,
  568. sum(case when follow_situation = 0 then 1 else 0 end) as sendMaterialNo, <!-- 已发项目介绍资料 -->
  569. sum(case when follow_situation = 1 then 1 else 0 end) as interviewNo, <!-- 已约面谈 -->
  570. sum(case when follow_situation = 2 then 1 else 0 end) as sendProspectusNo, <!-- 已发合同计划书 -->
  571. sum(case when follow_situation = 3 then 1 else 0 end) as quoteNo, <!-- 已报价 -->
  572. sum(case when follow_situation = 4 then 1 else 0 end) as sendContractNo, <!-- 已发合同 -->
  573. sum(case when follow_situation = 5 then 1 else 0 end) as signContractNo, <!-- 已签合同 -->
  574. sum(case when follow_situation = 6 then 1 else 0 end) as onVisaNo, <!-- 面谈中 -->
  575. sum(case when follow_situation = 7 then 1 else 0 end) as visaNo <!-- 已面签 -->
  576. from user_business where 1=1
  577. <if test="sDate != null">
  578. and create_time &gt; #{sDate,jdbcType=DATE}
  579. </if>
  580. <if test="eDate != null">
  581. and create_time &lt; #{eDate,jdbcType=DATE}
  582. </if>
  583. <if test="businessGlossoryId != null">
  584. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  585. </if>
  586. group by aid
  587. )a
  588. left join admin b on a.aid = b.id
  589. left join department_management c on b.department_id = c.id
  590. <if test="depNo !=null">
  591. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  592. </if>
  593. <if test="page_sql != null">
  594. ${page_sql}
  595. </if>
  596. </select>
  597. <select id="businessStatisticCount" resultType="java.lang.Integer">
  598. select count(0) from (
  599. select
  600. aid
  601. from user_business where 1=1
  602. <if test="sDate != null">
  603. and create_time &gt; #{sDate,jdbcType=DATE}
  604. </if>
  605. <if test="eDate != null">
  606. and create_time &lt; #{eDate,jdbcType=DATE}
  607. </if>
  608. <if test="businessGlossoryId != null">
  609. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  610. </if>
  611. group by aid
  612. )a
  613. left join admin b on a.aid = b.id
  614. left join department_management c on b.department_id = c.id
  615. <if test="depNo !=null">
  616. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  617. </if>
  618. </select>
  619. <select id="followStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  620. select x.*,b.name as adminName,c.name as departmentName,y.* from (
  621. select
  622. count(0) as followNo,
  623. aid,
  624. sum(case when contact_type = 0 then 1 else 0 end) as visitNo, <!-- 外出 -->
  625. sum(case when contact_type = 1 then 1 else 0 end) as telNo, <!-- 电话 -->
  626. sum(case when contact_type = 2 then 1 else 0 end) as qqNo, <!-- QQ -->
  627. sum(case when contact_type = 3 then 1 else 0 end) as wxNo, <!-- 微信 -->
  628. sum(case when contact_type = 4 then 1 else 0 end) as emailNo, <!-- 邮件 -->
  629. sum(case when contact_type = 5 then 1 else 0 end) as letterNo <!-- 书信 -->
  630. from user_follow where 1=1
  631. <if test="sDate != null">
  632. and create_time &gt; #{sDate,jdbcType=DATE}
  633. </if>
  634. <if test="eDate != null">
  635. and create_time &lt; #{eDate,jdbcType=DATE}
  636. </if>
  637. group by aid
  638. )x
  639. left join admin b on x.aid = b.id
  640. left join department_management c on b.department_id = c.id
  641. left join
  642. (
  643. select
  644. count( 0 ) as customerNo,
  645. aid
  646. from
  647. (
  648. select
  649. aid,
  650. uid
  651. from
  652. user_follow
  653. group by
  654. aid,
  655. uid
  656. ) a
  657. group by
  658. aid
  659. )y on x.aid = y.aid
  660. <if test="depNo !=null">
  661. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  662. </if>
  663. </select>
  664. <select id="followStatisticCount" resultType="java.lang.Integer">
  665. select count(0) from (
  666. select
  667. aid
  668. from user_follow where 1=1
  669. <if test="sDate != null">
  670. and create_time &gt; #{sDate,jdbcType=DATE}
  671. </if>
  672. <if test="sDate != null">
  673. and create_time &lt; #{eDate,jdbcType=DATE}
  674. </if>
  675. group by aid
  676. )x
  677. left join admin b on x.aid = b.id
  678. left join department_management c on b.department_id = c.id
  679. <if test="depNo !=null">
  680. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  681. </if>
  682. </select>
  683. <select id="findBusinessByFollowId" parameterType="java.lang.String" resultType="com.goafanti.common.model.UserBusiness">
  684. select
  685. a.id,
  686. a.follow_situation as followSituation,
  687. a.customer_status as customerStatus,
  688. a.remarks,
  689. a.business_glossory_id as businessGlossoryId
  690. from
  691. user_follow_business a
  692. where a.follow_id = #{followId,jdbcType=VARCHAR}
  693. </select>
  694. <select id="selectBusinessList" resultType="com.goafanti.customer.bo.BusinessListBo">
  695. select
  696. c.name as businessName,
  697. b.identify_name as identifyName,
  698. a.id as businessId,
  699. a.create_time as createTime,
  700. a.update_time as updateTime,
  701. a.follow_situation as followSituation,
  702. a.customer_status as customerStatus,
  703. d.name as adminName
  704. from
  705. user_business a inner join user b on
  706. a.uid = b.id left join business_glossory c on
  707. a.business_glossory_id = c.id left join admin d on
  708. a.aid = d.id
  709. where 1 = 1
  710. <if test="aid != null and aid != ''">
  711. and a.aid = #{aid,jdbcType=VARCHAR}
  712. </if>
  713. <if test="uid != null and uid !=''">
  714. and a.uid = #{uid,jdbcType=VARCHAR}
  715. </if>
  716. <if test="businessGlossoryId !=null and businessGlossoryId != ''">
  717. and a.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  718. </if>
  719. <if test="identifyName != null and identifyName != ''">
  720. and b.identify_name like concat('%', #{identifyName},'%')
  721. </if>
  722. <if test="followSituation != null">
  723. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  724. </if>
  725. <if test="customerStatus != null">
  726. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  727. </if>
  728. <if test="adminName != null and adminName != ''">
  729. and d.name = #{adminName,jdbcType=VARCHAR}
  730. </if>
  731. <if test="startDate != null and startDate != ''">
  732. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  733. </if>
  734. <if test="endDate != null and endDate != ''">
  735. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  736. </if>
  737. order by a.create_time desc
  738. <if test="page_sql != null">
  739. ${page_sql}
  740. </if>
  741. </select>
  742. <select id="selectBusinessCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
  743. select
  744. count(0)
  745. from
  746. user_business a inner join user b on
  747. a.uid = b.id left join business_glossory c on
  748. a.business_glossory_id = c.id left join admin d on
  749. a.aid = d.id
  750. where 1 = 1
  751. <if test="aid != null and aid != ''">
  752. and a.aid = #{aid,jdbcType=VARCHAR}
  753. </if>
  754. <if test="uid != null and uid !=''">
  755. and a.uid = #{uid,jdbcType=VARCHAR}
  756. </if>
  757. <if test="businessGlossoryId !=null and businessGlossoryId != ''">
  758. and a.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  759. </if>
  760. <if test="identifyName != null and identifyName != ''">
  761. and b.identify_name like concat('%', #{identifyName},'%')
  762. </if>
  763. <if test="followSituation != null">
  764. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  765. </if>
  766. <if test="customerStatus != null">
  767. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  768. </if>
  769. <if test="adminName != null and adminName != ''">
  770. and d.name = #{adminName,jdbcType=VARCHAR}
  771. </if>
  772. <if test="startDate != null and startDate != ''">
  773. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  774. </if>
  775. <if test="endDate != null and endDate != ''">
  776. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  777. </if>
  778. </select>
  779. <select id="selectBusinessManageList" resultType="com.goafanti.customer.bo.BusinessListBo">
  780. select
  781. c.name as businessName,
  782. b.identify_name as identifyName,
  783. a.id as businessId,
  784. a.create_time as createTime,
  785. a.update_time as updateTime,
  786. a.follow_situation as followSituation,
  787. a.customer_status as customerStatus,
  788. d.name as adminName
  789. from
  790. user_business a inner join user b on
  791. a.uid = b.id left join business_glossory c on
  792. a.business_glossory_id = c.id left join admin d on
  793. a.aid = d.id
  794. LEFT JOIN department_management dm on dm.id = d.department_id
  795. where 1 = 1
  796. <if test="aid != null and aid != ''">
  797. and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  798. </if>
  799. <if test="uid != null and uid !=''">
  800. and a.uid = #{uid,jdbcType=VARCHAR}
  801. </if>
  802. <if test="businessGlossoryId !=null and businessGlossoryId != ''">
  803. and a.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  804. </if>
  805. <if test="identifyName != null and identifyName != ''">
  806. and b.identify_name like concat('%', #{identifyName},'%')
  807. </if>
  808. <if test="followSituation != null">
  809. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  810. </if>
  811. <if test="customerStatus != null">
  812. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  813. </if>
  814. <if test="adminName != null and adminName != ''">
  815. and d.name = #{adminName,jdbcType=VARCHAR}
  816. </if>
  817. <if test="startDate != null and startDate != ''">
  818. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  819. </if>
  820. <if test="endDate != null and endDate != ''">
  821. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  822. </if>
  823. order by a.create_time desc
  824. <if test="page_sql != null">
  825. ${page_sql}
  826. </if>
  827. </select>
  828. <select id="selectBusinessManageCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
  829. select
  830. count(0)
  831. from
  832. user_business a inner join user b on
  833. a.uid = b.id left join business_glossory c on
  834. a.business_glossory_id = c.id left join admin d on
  835. a.aid = d.id
  836. LEFT JOIN department_management dm on dm.id = d.department_id
  837. where 1 = 1
  838. <if test="aid != null and aid != ''">
  839. and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  840. </if>
  841. <if test="uid != null and uid !=''">
  842. and a.uid = #{uid,jdbcType=VARCHAR}
  843. </if>
  844. <if test="businessGlossoryId !=null and businessGlossoryId != ''">
  845. and a.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  846. </if>
  847. <if test="identifyName != null and identifyName != ''">
  848. and b.identify_name like concat('%', #{identifyName},'%')
  849. </if>
  850. <if test="followSituation != null">
  851. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  852. </if>
  853. <if test="customerStatus != null">
  854. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  855. </if>
  856. <if test="adminName != null and adminName != ''">
  857. and d.name = #{adminName,jdbcType=VARCHAR}
  858. </if>
  859. <if test="startDate != null and startDate != ''">
  860. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  861. </if>
  862. <if test="endDate != null and endDate != ''">
  863. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  864. </if>
  865. </select>
  866. <select id="selectManagePersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  867. select
  868. a.id as uid,
  869. a.type,
  870. a.status,
  871. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  872. a.business_audit as businessAudit,
  873. a.current_member_status as currentMemberStatus,
  874. a.identify_name as name,
  875. a.lvl,a.is_member as isMember,
  876. a.society_tag as societyTag,
  877. a.share_type as shareType,
  878. b.contacts,
  879. b.contact_mobile as contactMobile,
  880. b.international,
  881. b.expert,
  882. b.audit_status as auditStatus,
  883. dg1.name as province,
  884. dg2.name as city,
  885. dg3.name as area,
  886. c.name as industry,
  887. d.name as adminName,
  888. b.expert_audit as expertAudit,
  889. b.release_status as releaseStatus
  890. from user a inner join user_identity b on a.id = b.uid
  891. left join district_glossory dg1 on b.province = dg1.id
  892. left join district_glossory dg2 on b.city = dg2.id
  893. left join district_glossory dg3 on b.area = dg3.id
  894. left join industry_category c on b.industry = c.id
  895. left join admin d on a.aid = d.id
  896. LEFT JOIN department_management dm on dm.id = d.department_id
  897. where a.type = 0 and a.status != 1 and a.audit_status = 1
  898. and a.share_type =0
  899. <if test="aid != null and aid !=''">
  900. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  901. </if>
  902. <if test="name != null and name != ''">
  903. and a.identify_name like concat('%',#{name},'%')
  904. </if>
  905. <if test="shareType != null">
  906. and a.share_type = #{shareType,jdbcType=INTEGER}
  907. </if>
  908. <if test="status != null">
  909. and a.status = #{status,jdbcType=INTEGER}
  910. </if>
  911. <if test="businessAudit != null">
  912. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  913. </if>
  914. <if test="isMember != null">
  915. and a.is_member = #{isMember,jdbcType=INTEGER}
  916. </if>
  917. <if test="lvl != null">
  918. and a.lvl = #{lvl,jdbcType=INTEGER}
  919. </if>
  920. <if test="currentMemberStatus != null">
  921. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  922. </if>
  923. <if test="societyTag != null and societyTag != ''">
  924. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  925. </if>
  926. <if test="startDate != null and startDate != ''">
  927. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  928. </if>
  929. <if test="endDate != null and endDate != ''">
  930. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  931. </if>
  932. <if test="province != null">
  933. and b.province = #{province,jdbcType=INTEGER}
  934. </if>
  935. <if test="city != null">
  936. and b.city = #{city,jdbcType=INTEGER}
  937. </if>
  938. <if test="area != null">
  939. and b.area = #{area,jdbcType=INTEGER}
  940. </if>
  941. <if test="industry != null">
  942. and b.industry = #{industry,jdbcType=INTEGER}
  943. </if>
  944. <if test="expert != null">
  945. and b.expert = #{expert,jdbcType=INTEGER}
  946. </if>
  947. <if test="international != null">
  948. and b.international = #{international,jdbcType=INTEGER}
  949. </if>
  950. <if test="auditStatus != null">
  951. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  952. </if>
  953. <if test="page_sql != null">
  954. ${page_sql}
  955. </if>
  956. </select>
  957. <select id="selectManagePersonalCustomerCount" resultType="java.lang.Integer">
  958. select count(0)
  959. from user a inner join user_identity b on a.id = b.uid
  960. left join admin d on a.aid = d.id
  961. LEFT JOIN department_management dm on dm.id = d.department_id
  962. where a.type = 0 and a.status != 1 and a.audit_status = 1
  963. <if test="aid != null and aid !=''">
  964. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  965. </if>
  966. <if test="name != null and name != ''">
  967. and a.identify_name like concat('%',#{name},'%')
  968. </if>
  969. <if test="shareType != null">
  970. and a.share_type = #{shareType,jdbcType=VARCHAR}
  971. </if>
  972. <if test="status != null">
  973. and a.status = #{status,jdbcType=INTEGER}
  974. </if>
  975. <if test="businessAudit != null">
  976. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  977. </if>
  978. <if test="isMember != null">
  979. and a.is_member = #{isMember,jdbcType=INTEGER}
  980. </if>
  981. <if test="lvl != null">
  982. and a.lvl = #{lvl,jdbcType=INTEGER}
  983. </if>
  984. <if test="currentMemberStatus != null">
  985. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  986. </if>
  987. <if test="societyTag != null and societyTag != ''">
  988. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  989. </if>
  990. <if test="startDate != null and startDate != ''">
  991. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  992. </if>
  993. <if test="endDate != null and endDate != ''">
  994. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  995. </if>
  996. <if test="province != null">
  997. and b.province = #{province,jdbcType=INTEGER}
  998. </if>
  999. <if test="city != null">
  1000. and b.city = #{city,jdbcType=INTEGER}
  1001. </if>
  1002. <if test="area != null">
  1003. and b.area = #{area,jdbcType=INTEGER}
  1004. </if>
  1005. <if test="industry != null">
  1006. and b.industry = #{industry,jdbcType=INTEGER}
  1007. </if>
  1008. <if test="expert != null">
  1009. and b.expert = #{expert,jdbcType=INTEGER}
  1010. </if>
  1011. <if test="international != null">
  1012. and b.international = #{international,jdbcType=INTEGER}
  1013. </if>
  1014. <if test="auditStatus != null">
  1015. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  1016. </if>
  1017. </select>
  1018. <select id="selectManageOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1019. select
  1020. a.id as uid,
  1021. a.type,
  1022. a.status,
  1023. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  1024. a.business_audit as businessAudit,
  1025. a.current_member_status as currentMemberStatus,
  1026. a.identify_name as name,
  1027. a.lvl,
  1028. a.is_member as isMember,
  1029. a.society_tag as societyTag,
  1030. share_type as shareType,
  1031. b.contacts,
  1032. b.contact_mobile as contactMobile,
  1033. b.international,
  1034. b.listed,
  1035. b.high_tech_zone as highTechZone,
  1036. b.audit_status as auditStatus,
  1037. dg1.name as province,
  1038. dg2.name as city,
  1039. dg3.name as area,
  1040. c.name as industry,
  1041. d.name as adminName
  1042. from user a inner join organization_identity b on a.id = b.uid
  1043. left join district_glossory dg1 on b.location_province = dg1.id
  1044. left join district_glossory dg2 on b.location_city = dg2.id
  1045. left join district_glossory dg3 on b.location_area = dg3.id
  1046. left join industry_category c on b.industry = c.id
  1047. left join admin d on a.aid = d.id
  1048. LEFT JOIN department_management dm on dm.id = d.department_id
  1049. where a.type = 1 and a.status != 1 and a.audit_status = 1
  1050. <if test="aid != null and aid !=''">
  1051. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1052. </if>
  1053. <if test="name != null and name != ''">
  1054. and a.identify_name like concat('%',#{name},'%')
  1055. </if>
  1056. <if test="shareType != null">
  1057. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1058. </if>
  1059. <if test="status != null">
  1060. and a.status = #{status,jdbcType=INTEGER}
  1061. </if>
  1062. <if test="businessAudit != null">
  1063. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  1064. </if>
  1065. <if test="isMember != null">
  1066. and a.is_member = #{isMember,jdbcType=INTEGER}
  1067. </if>
  1068. <if test="currentMemberStatus != null">
  1069. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  1070. </if>
  1071. <if test="lvl != null">
  1072. and a.lvl = #{lvl,jdbcType=INTEGER}
  1073. </if>
  1074. <if test="societyTag != null and societyTag != ''">
  1075. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1076. </if>
  1077. <if test="startDate != null and startDate != ''">
  1078. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1079. </if>
  1080. <if test="endDate != null and endDate != ''">
  1081. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1082. </if>
  1083. <if test="province != null">
  1084. and b.location_province = #{province,jdbcType=INTEGER}
  1085. </if>
  1086. <if test="city != null">
  1087. and b.location_city = #{city,jdbcType=INTEGER}
  1088. </if>
  1089. <if test="area != null">
  1090. and b.location_area = #{area,jdbcType=INTEGER}
  1091. </if>
  1092. <if test="industry != null">
  1093. and b.industry = #{industry,jdbcType=INTEGER}
  1094. </if>
  1095. <if test="listed != null">
  1096. and b.listed = #{listed,jdbcType=INTEGER}
  1097. </if>
  1098. <if test="highTechZone != null">
  1099. and b.high_tech_zone = #{highTechZone,jdbcType=INTEGER}
  1100. </if>
  1101. <if test="international != null">
  1102. and b.international = #{international,jdbcType=INTEGER}
  1103. </if>
  1104. <if test="auditStatus != null">
  1105. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  1106. </if>
  1107. <if test="page_sql != null">
  1108. ${page_sql}
  1109. </if>
  1110. </select>
  1111. <select id="selectManageOrganizationCustomerCount" resultType="java.lang.Integer">
  1112. select
  1113. count(0)
  1114. from user a inner join organization_identity b on a.id = b.uid
  1115. left join admin d on a.aid = d.id
  1116. LEFT JOIN department_management dm on dm.id = d.department_id
  1117. where a.type = 1 and a.status != 1 and a.audit_status = 1
  1118. <if test="aid != null and aid !=''">
  1119. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1120. </if>
  1121. <if test="name != null and name != ''">
  1122. and a.identify_name like concat('%',#{name},'%')
  1123. </if>
  1124. <if test="shareType != null">
  1125. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1126. </if>
  1127. <if test="status != null">
  1128. and a.status = #{status,jdbcType=INTEGER}
  1129. </if>
  1130. <if test="businessAudit != null">
  1131. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  1132. </if>
  1133. <if test="currentMemberStatus != null">
  1134. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  1135. </if>
  1136. <if test="isMember != null">
  1137. and a.is_member = #{isMember,jdbcType=INTEGER}
  1138. </if>
  1139. <if test="societyTag != null and societyTag != ''">
  1140. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1141. </if>
  1142. <if test="startDate != null and startDate != ''">
  1143. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1144. </if>
  1145. <if test="endDate != null and endDate != ''">
  1146. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1147. </if>
  1148. <if test="province != null">
  1149. and b.location_province = #{province,jdbcType=INTEGER}
  1150. </if>
  1151. <if test="city != null">
  1152. and b.location_city = #{city,jdbcType=INTEGER}
  1153. </if>
  1154. <if test="area != null">
  1155. and b.location_area = #{area,jdbcType=INTEGER}
  1156. </if>
  1157. <if test="industry != null">
  1158. and b.industry = #{industry,jdbcType=INTEGER}
  1159. </if>
  1160. <if test="listed != null">
  1161. and b.listed = #{listed,jdbcType=INTEGER}
  1162. </if>
  1163. <if test="highTechZone != null">
  1164. and b.high_tech_zone = #{highTechZone,jdbcType=INTEGER}
  1165. </if>
  1166. <if test="international != null">
  1167. and b.international = #{international,jdbcType=INTEGER}
  1168. </if>
  1169. <if test="auditStatus != null">
  1170. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  1171. </if>
  1172. </select>
  1173. <select id="findAdminName" resultType="com.goafanti.customer.bo.CustomerListOut">
  1174. select d.name as adminName,d.id as aid
  1175. from admin d left join department_management dm on dm.id = d.department_id
  1176. where d.department_id=(select department_id from admin where id=#{aid,jdbcType=INTEGER})
  1177. </select>
  1178. <select id="findEnteringAuditList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1179. select u.id as uid,u.nickname as name,u.mobile as contactMobile,a.name as adminName,u.create_time as createTime,u.audit_status as auditStatus
  1180. from user u left join admin a on u.aid=a.id
  1181. where u.audit_status=0 and u.status != 1 and u.share_type=0
  1182. <if test="aid != null and aid !=''">
  1183. and u.aid = #{aid,jdbcType=VARCHAR}
  1184. </if>
  1185. <if test="name != null and name != ''">
  1186. and u.nickname = #{name,jdbcType=VARCHAR}
  1187. </if>
  1188. <if test="adminName != null and adminName != ''">
  1189. and a.name = #{adminName,jdbcType=VARCHAR}
  1190. </if>
  1191. <if test="page_sql != null">
  1192. ${page_sql}
  1193. </if>
  1194. </select>
  1195. <select id="findEnteringAuditCount" resultType="java.lang.Integer">
  1196. select
  1197. count(0)
  1198. from user u left join admin a on u.aid=a.id
  1199. where u.audit_status=0 and u.status != 1 and u.share_type=0
  1200. <if test="aid != null and aid !=''">
  1201. and u.aid = #{aid,jdbcType=VARCHAR}
  1202. </if>
  1203. <if test="name != null and name != ''">
  1204. and u.nickname = #{name,jdbcType=VARCHAR}
  1205. </if>
  1206. <if test="adminName != null and adminName != ''">
  1207. and a.name = #{adminName,jdbcType=VARCHAR}
  1208. </if>
  1209. </select>
  1210. <select id="findEnteringAuditIsNoList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1211. select u.id as uid,u.nickname as name,u.mobile as contactMobile,a.name as adminName,u.create_time as createTime,
  1212. u.audit_status as auditStatus,u.audit_opinion as auditOpinion,u.society_tag as societyTag
  1213. from user u left join admin a on u.aid=a.id
  1214. where u.audit_status=2 and u.status != 1
  1215. <if test="aid != null and aid !=''">
  1216. and u.aid = #{aid,jdbcType=VARCHAR}
  1217. </if>
  1218. <if test="name != null and name != ''">
  1219. and u.nickname = #{name,jdbcType=VARCHAR}
  1220. </if>
  1221. <if test="adminName != null and adminName != ''">
  1222. and a.name = #{adminName,jdbcType=VARCHAR}
  1223. </if>
  1224. <if test="page_sql != null">
  1225. ${page_sql}
  1226. </if>
  1227. </select>
  1228. <select id="findEnteringAuditIsNoCount" resultType="java.lang.Integer">
  1229. select
  1230. count(0)
  1231. from user u left join admin a on u.aid=a.id
  1232. where u.audit_status=2 and u.status != 1
  1233. <if test="aid != null and aid !=''">
  1234. and u.aid = #{aid,jdbcType=VARCHAR}
  1235. </if>
  1236. <if test="name != null and name != ''">
  1237. and u.nickname = #{name,jdbcType=VARCHAR}
  1238. </if>
  1239. <if test="adminName != null and adminName != ''">
  1240. and a.name = #{adminName,jdbcType=VARCHAR}
  1241. </if>
  1242. </select>
  1243. <update id="updateRefusedCustomer" parameterType="map">
  1244. update user
  1245. set
  1246. nickname = #{nickname,jdbcType=VARCHAR},
  1247. mobile = #{mobile,jdbcType=VARCHAR},
  1248. society_tag = #{societyTag,jdbcType=VARCHAR},
  1249. audit_status=0
  1250. where id = #{id,jdbcType=VARCHAR}
  1251. </update>
  1252. </mapper>