UserMapperExt.xml 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976
  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.identify_name as name,
  8. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  9. dg1.name as province,
  10. dg2.name as city,
  11. dg3.name as area,
  12. d.name as adminName
  13. from user a
  14. left join user_identity b on a.id = b.uid
  15. left join district_glossory dg1 on b.province = dg1.id
  16. left join district_glossory dg2 on b.city = dg2.id
  17. left join district_glossory dg3 on b.area = dg3.id
  18. left join admin d on a.aid = d.id
  19. where a.type = 0 and a.status != 1
  20. <if test="aid != null and aid !=''">
  21. and a.aid = #{aid,jdbcType=VARCHAR}
  22. </if>
  23. <if test="name != null and name != ''">
  24. and a.identify_name like concat('%',#{name},'%')
  25. </if>
  26. <if test="startDate != null and startDate != ''">
  27. and a.transfer_time &gt; #{startDate}
  28. </if>
  29. <if test="endDate != null and endDate != ''">
  30. and a.transfer_time &lt; #{endDate}
  31. </if>
  32. <if test="province != null">
  33. and b.province = #{province,jdbcType=INTEGER}
  34. </if>
  35. <if test="city != null">
  36. and b.city = #{city,jdbcType=INTEGER}
  37. </if>
  38. <if test="area != null">
  39. and b.area = #{area,jdbcType=INTEGER}
  40. </if>
  41. <if test="page_sql != null">
  42. ${page_sql}
  43. </if>
  44. </select>
  45. <select id="selectPersonalCustomerCount" resultType="java.lang.Integer">
  46. select
  47. count(0)
  48. from user a
  49. left join user_identity b on a.id = b.uid
  50. left join district_glossory dg1 on b.province = dg1.id
  51. left join district_glossory dg2 on b.city = dg2.id
  52. left join district_glossory dg3 on b.area = dg3.id
  53. left join admin d on a.aid = d.id
  54. where a.type = 0 and a.status != 1
  55. <if test="aid != null and aid !=''">
  56. and a.aid = #{aid,jdbcType=VARCHAR}
  57. </if>
  58. <if test="name != null and name != ''">
  59. and a.identify_name like concat('%',#{name},'%')
  60. </if>
  61. <if test="startDate != null and startDate != ''">
  62. and a.transfer_time &gt; #{startDate}
  63. </if>
  64. <if test="endDate != null and endDate != ''">
  65. and a.transfer_time &lt; #{endDate}
  66. </if>
  67. <if test="province != null">
  68. and b.province = #{province,jdbcType=INTEGER}
  69. </if>
  70. <if test="city != null">
  71. and b.city = #{city,jdbcType=INTEGER}
  72. </if>
  73. <if test="area != null">
  74. and b.area = #{area,jdbcType=INTEGER}
  75. </if>
  76. </select>
  77. <select id="selectPrivatePersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  78. select t0.id as uid,
  79. t0.aid,
  80. date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
  81. date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  82. t0.identify_name as name,
  83. t0.society_tag as societyTag,
  84. date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
  85. date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
  86. b.contacts,
  87. b.contact_mobile as contactMobile,
  88. dg1.name as province,
  89. dg2.name as city,
  90. dg3.name as area,
  91. ifnull(t1.last_follow_time,t0.transfer_time) as orderTime,
  92. c.name as industry,
  93. d.name as adminName
  94. from
  95. (select id,aid,type,share_type,create_time,transfer_time,identify_name,society_tag from user where aid = #{aid} and type = 0 and share_type = 0 and status != 1)t0
  96. left join
  97. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
  98. on t0.id = t1.uid left join
  99. (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid} group by uid)t2
  100. on t0.id = t2.uid
  101. left join user_identity b on t0.id = b.uid
  102. left join district_glossory dg1 on b.province = dg1.id
  103. left join district_glossory dg2 on b.city = dg2.id
  104. left join district_glossory dg3 on b.area = dg3.id
  105. left join industry_category c on b.industry = c.id
  106. left join admin d on t0.aid = d.id where 1=1
  107. <if test="name != null and name != ''">
  108. and t0.identify_name like concat('%',#{name},'%')
  109. </if>
  110. <if test="startDate != null and startDate != ''">
  111. and t0.transfer_time &gt; #{startDate}
  112. </if>
  113. <if test="endDate != null and endDate != ''">
  114. and t0.transfer_time &lt; #{endDate}
  115. </if>
  116. <if test="province != null">
  117. and b.province = #{province,jdbcType=INTEGER}
  118. </if>
  119. <if test="city != null">
  120. and b.city = #{city,jdbcType=INTEGER}
  121. </if>
  122. <if test="area != null">
  123. and b.area = #{area,jdbcType=INTEGER}
  124. </if>
  125. order by orderTime
  126. <if test="page_sql != null">
  127. ${page_sql}
  128. </if>
  129. </select>
  130. <select id="selectPrivatePersonalCustomerCount" resultType="java.lang.Integer">
  131. select count(0)
  132. from
  133. (select id,aid,type,share_type,transfer_time,identify_name,society_tag from user where aid = #{aid} and type = 0 and share_type = 0 and status != 1)t0
  134. left join user_identity b on t0.id = b.uid where 1=1
  135. <if test="name != null and name != ''">
  136. and t0.identify_name like concat('%',#{name},'%')
  137. </if>
  138. <if test="startDate != null and startDate != ''">
  139. and t0.transfer_time &gt; #{startDate}
  140. </if>
  141. <if test="endDate != null and endDate != ''">
  142. and t0.transfer_time &lt; #{endDate}
  143. </if>
  144. <if test="province != null">
  145. and b.province = #{province,jdbcType=INTEGER}
  146. </if>
  147. <if test="city != null">
  148. and b.city = #{city,jdbcType=INTEGER}
  149. </if>
  150. <if test="area != null">
  151. and b.area = #{area,jdbcType=INTEGER}
  152. </if>
  153. </select>
  154. <select id="selectPublicPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  155. select
  156. a.id as uid,
  157. a.aid,
  158. a.identify_name as name,
  159. a.create_time as createTime,
  160. a.transfer_time as transferTime,
  161. b.contacts,
  162. b.contact_mobile as contactMobile,
  163. dg1.name as province,
  164. dg2.name as city,
  165. dg3.name as area
  166. from
  167. user a inner join user_identity b on a.id = b.uid
  168. left join district_glossory dg1 on b.province = dg1.id
  169. left join district_glossory dg2 on b.city = dg2.id
  170. left join district_glossory dg3 on b.area = dg3.id
  171. where
  172. a.type = 0 and a.share_type = 1 and a.status != 1
  173. <if test="aid != null and aid !=''">
  174. and a.aid = #{aid,jdbcType=VARCHAR}
  175. </if>
  176. <if test="name != null and name != ''">
  177. and a.identify_name like concat('%',#{name},'%')
  178. </if>
  179. <if test="startDate != null and startDate != ''">
  180. and a.transfer_time &gt; #{startDate}
  181. </if>
  182. <if test="endDate != null and endDate != ''">
  183. and a.transfer_time &lt; #{endDate}
  184. </if>
  185. <if test="province != null">
  186. and b.province = #{province,jdbcType=INTEGER}
  187. </if>
  188. <if test="city != null">
  189. and b.city = #{city,jdbcType=INTEGER}
  190. </if>
  191. <if test="area != null">
  192. and b.area = #{area,jdbcType=INTEGER}
  193. </if>
  194. <if test="page_sql != null">
  195. ${page_sql}
  196. </if>
  197. </select>
  198. <select id="selectPublicPersonalCustomerCount" resultType="java.lang.Integer">
  199. select
  200. count(0)
  201. from
  202. user a inner join user_identity b on a.id = b.uid
  203. left join district_glossory dg1 on b.province = dg1.id
  204. left join district_glossory dg2 on b.city = dg2.id
  205. left join district_glossory dg3 on b.area = dg3.id
  206. where
  207. a.type = 0 and a.share_type = 1 and a.status != 1
  208. <if test="aid != null and aid !=''">
  209. and a.aid = #{aid,jdbcType=VARCHAR}
  210. </if>
  211. <if test="name != null and name != ''">
  212. and a.identify_name like concat('%',#{name},'%')
  213. </if>
  214. <if test="startDate != null and startDate != ''">
  215. and a.transfer_time &gt; #{startDate}
  216. </if>
  217. <if test="endDate != null and endDate != ''">
  218. and a.transfer_time &lt; #{endDate}
  219. </if>
  220. <if test="province != null">
  221. and b.province = #{province,jdbcType=INTEGER}
  222. </if>
  223. <if test="city != null">
  224. and b.city = #{city,jdbcType=INTEGER}
  225. </if>
  226. <if test="area != null">
  227. and b.area = #{area,jdbcType=INTEGER}
  228. </if>
  229. </select>
  230. <select id="selectSignPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  231. select
  232. t0.uid as uid,
  233. date_format(t0.update_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
  234. date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
  235. t2.society_tag as societyTag,
  236. t2.identify_name as name,
  237. t2.share_type as shareType,
  238. date_format(t2.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
  239. dg1.name as province,
  240. dg2.name as city,
  241. dg3.name as area,
  242. b.contacts,
  243. b.contact_mobile as contactMobile,
  244. c.name as industry,
  245. d.name as adminName
  246. from
  247. (select uid,aid,max(lock_time) as update_time
  248. from user_lock_release
  249. where type=1 and aid= #{aid,jdbcType=VARCHAR}
  250. group by uid)t0
  251. left join
  252. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid =#{aid,jdbcType=VARCHAR} group by uid)t1
  253. on t0.uid = t1.uid
  254. inner join
  255. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
  256. on t0.uid = t2.id
  257. left join user_identity b on t0.uid = b.uid
  258. left join district_glossory dg1 on b.province = dg1.id
  259. left join district_glossory dg2 on b.city = dg2.id
  260. left join district_glossory dg3 on b.area = dg3.id
  261. left join industry_category c on b.industry = c.id
  262. left join admin d on t2.aid = d.id where 1 = 1
  263. <if test="name != null and name != ''">
  264. and t2.identify_name like concat('%',#{name},'%')
  265. </if>
  266. <if test="shareType != null">
  267. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  268. </if>
  269. <if test="startDate != null and startDate != ''">
  270. and t2.transfer_time &gt; #{startDate}
  271. </if>
  272. <if test="endDate != null and endDate != ''">
  273. and t2.transfer_time &lt; #{endDate}
  274. </if>
  275. <if test="province != null">
  276. and b.province = #{province,jdbcType=INTEGER}
  277. </if>
  278. <if test="city != null">
  279. and b.city = #{city,jdbcType=INTEGER}
  280. </if>
  281. <if test="area != null">
  282. and b.area = #{area,jdbcType=INTEGER}
  283. </if>
  284. <if test="page_sql != null">
  285. ${page_sql}
  286. </if>
  287. </select>
  288. <select id="selectSignPersonalCustomerCount" resultType="java.lang.Integer">
  289. select
  290. count(0)
  291. from
  292. (select uid,aid,max(lock_time) as update_time
  293. from user_lock_release
  294. where type=1 and aid= #{aid,jdbcType=VARCHAR}
  295. group by uid)t0
  296. <!-- (select uid,max(lock_time) from user_lock_release where aid = #{aid} and type = 1 and status = 0 group by uid)t0 -->
  297. inner join
  298. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
  299. on t0.uid = t2.id
  300. left join user_identity b on t0.uid = b.uid
  301. where 1 = 1
  302. <if test="name != null and name != ''">
  303. and t2.identify_name like concat('%',#{name},'%')
  304. </if>
  305. <if test="shareType != null">
  306. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  307. </if>
  308. <if test="startDate != null and startDate != ''">
  309. and t2.transfer_time &gt; #{startDate}
  310. </if>
  311. <if test="endDate != null and endDate != ''">
  312. and t2.transfer_time &lt; #{endDate}
  313. </if>
  314. <if test="province != null">
  315. and b.province = #{province,jdbcType=INTEGER}
  316. </if>
  317. <if test="city != null">
  318. and b.city = #{city,jdbcType=INTEGER}
  319. </if>
  320. <if test="area != null">
  321. and b.area = #{area,jdbcType=INTEGER}
  322. </if>
  323. </select>
  324. <select id="selectOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  325. select
  326. a.id as uid,
  327. a.identify_name as name,
  328. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  329. dg1.name as province,
  330. dg2.name as city,
  331. dg3.name as area,
  332. a.aid,
  333. a.share_type as shareType,
  334. a.information_maintainer as mid
  335. from user a
  336. left join organization_identity b on a.id = b.uid
  337. left join district_glossory dg1 on b.location_province = dg1.id
  338. left join district_glossory dg2 on b.location_city = dg2.id
  339. left join district_glossory dg3 on b.location_area = dg3.id
  340. left join admin d on a.aid = d.id
  341. where a.type = 1 and a.status != 1
  342. <if test="aid != null and aid !=''">
  343. and a.aid = #{aid,jdbcType=VARCHAR}
  344. </if>
  345. <if test="departmentId != null and departmentId !=''">
  346. and d.department_id=#{departmentId,jdbcType=VARCHAR}
  347. </if>
  348. <if test="name != null and name != ''">
  349. and a.identify_name like concat('%',#{name},'%')
  350. </if>
  351. <if test="startDate != null and startDate != ''">
  352. and a.transfer_time &gt; #{startDate}
  353. </if>
  354. <if test="endDate != null and endDate != ''">
  355. and a.transfer_time &lt; #{endDate}
  356. </if>
  357. <if test="province != null">
  358. and b.location_province = #{province,jdbcType=INTEGER}
  359. </if>
  360. <if test="city != null">
  361. and b.location_city = #{city,jdbcType=INTEGER}
  362. </if>
  363. <if test="area != null">
  364. and b.location_area = #{area,jdbcType=INTEGER}
  365. </if>
  366. <if test="page_sql != null">
  367. ${page_sql}
  368. </if>
  369. </select>
  370. <select id="selectOrganizationCustomerCount" resultType="java.lang.Integer">
  371. select
  372. count(0)
  373. from user a
  374. left join organization_identity b on a.id = b.uid
  375. <if test="departmentId != null and departmentId !=''">
  376. INNER join (select id
  377. from admin
  378. where department_id=#{departmentId,jdbcType=VARCHAR}) d on a.aid = d.id
  379. </if>
  380. where a.type = 1 and a.status != 1
  381. <if test="aid != null and aid !=''">
  382. and a.aid = #{aid,jdbcType=VARCHAR}
  383. </if>
  384. <if test="name != null and name != ''">
  385. and a.identify_name like concat('%',#{name},'%')
  386. </if>
  387. <if test="startDate != null and startDate != ''">
  388. and a.transfer_time &gt; #{startDate}
  389. </if>
  390. <if test="endDate != null and endDate != ''">
  391. and a.transfer_time &lt; #{endDate}
  392. </if>
  393. <if test="province != null">
  394. and b.location_province = #{province,jdbcType=INTEGER}
  395. </if>
  396. <if test="city != null">
  397. and b.location_city = #{city,jdbcType=INTEGER}
  398. </if>
  399. <if test="area != null">
  400. and b.location_area = #{area,jdbcType=INTEGER}
  401. </if>
  402. </select>
  403. <select id="selectPrivateOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  404. select t0.id as uid,
  405. t0.aid,
  406. date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
  407. date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  408. t0.identify_name as name,
  409. t0.society_tag as societyTag,
  410. t0.level,
  411. date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
  412. date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
  413. b.contacts,
  414. b.contact_mobile as contactMobile,
  415. dg1.name as province,
  416. dg2.name as city,
  417. dg3.name as area,
  418. c.name as industry,
  419. if(t0.transfer_time &lt; t1.last_follow_time,t1.last_follow_time,t0.transfer_time) as orderTime,
  420. d.name as adminName
  421. from
  422. (select id,aid,type,share_type,transfer_time,create_time,identify_name,society_tag,level from user where aid = #{aid} and type = 1 and share_type = 0 and status != 1)t0
  423. left join
  424. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
  425. on t0.id = t1.uid left join
  426. (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid} group by uid)t2
  427. on t0.id = t2.uid
  428. left join organization_identity b on t0.id = b.uid
  429. left join district_glossory dg1 on b.location_province = dg1.id
  430. left join district_glossory dg2 on b.location_city = dg2.id
  431. left join district_glossory dg3 on b.location_area = dg3.id
  432. left join industry_category c on b.industry = c.id
  433. left join admin d on t0.aid = d.id where 1=1
  434. <if test="aid != null and aid !=''">
  435. and t0.aid = #{aid,jdbcType=VARCHAR}
  436. </if>
  437. <if test="name != null and name != ''">
  438. and t0.identify_name like concat('%',#{name},'%')
  439. </if>
  440. <if test="startDate != null and startDate != ''">
  441. and t0.transfer_time &gt; #{startDate}
  442. </if>
  443. <if test="endDate != null and endDate != ''">
  444. and t0.transfer_time &lt; #{endDate}
  445. </if>
  446. <if test="province != null">
  447. and b.location_province = #{province,jdbcType=INTEGER}
  448. </if>
  449. <if test="city != null">
  450. and b.location_city = #{city,jdbcType=INTEGER}
  451. </if>
  452. <if test="area != null">
  453. and b.location_area = #{area,jdbcType=INTEGER}
  454. </if>
  455. <if test="level != null">
  456. and t0.level = #{level,jdbcType=INTEGER}
  457. </if>
  458. order by orderTime
  459. <if test="page_sql != null">
  460. ${page_sql}
  461. </if>
  462. </select>
  463. <select id="selectPrivateOrganizationCustomerCount" resultType="java.lang.Integer">
  464. select
  465. count(0)
  466. from
  467. (select id,aid,type,share_type,transfer_time,identify_name,society_tag,level from user where aid = #{aid} and type = 1 and share_type = 0 and status != 1)t0
  468. left join organization_identity b on t0.id = b.uid where 1=1
  469. <if test="aid != null and aid !=''">
  470. and t0.aid = #{aid,jdbcType=VARCHAR}
  471. </if>
  472. <if test="name != null and name != ''">
  473. and t0.identify_name like concat('%',#{name},'%')
  474. </if>
  475. <if test="startDate != null and startDate != ''">
  476. and t0.transfer_time &gt; #{startDate}
  477. </if>
  478. <if test="endDate != null and endDate != ''">
  479. and t0.transfer_time &lt; #{endDate}
  480. </if>
  481. <if test="province != null">
  482. and b.location_province = #{province,jdbcType=INTEGER}
  483. </if>
  484. <if test="city != null">
  485. and b.location_city = #{city,jdbcType=INTEGER}
  486. </if>
  487. <if test="area != null">
  488. and b.location_area = #{area,jdbcType=INTEGER}
  489. </if>
  490. <if test="level != null">
  491. and t0.level = #{level,jdbcType=INTEGER}
  492. </if>
  493. </select>
  494. <select id="selectPublicOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  495. select
  496. a.id as uid,
  497. a.identify_name as name,
  498. a.create_time as createTime,
  499. a.transfer_time as transferTime,
  500. b.contacts,
  501. b.contact_mobile as contactMobile,
  502. dg1.name as province,
  503. dg2.name as city,
  504. dg3.name as area
  505. from
  506. user a
  507. inner join organization_identity b on a.id = b.uid
  508. left join district_glossory dg1 on b.location_province = dg1.id
  509. left join district_glossory dg2 on b.location_city = dg2.id
  510. left join district_glossory dg3 on b.location_area = dg3.id
  511. where
  512. a.type = 1
  513. and a.share_type = 1
  514. and a.status != 1
  515. <if test="aid != null and aid !=''">
  516. and a..aid = #{aid,jdbcType=VARCHAR}
  517. </if>
  518. <if test="name != null and name != ''">
  519. and a.identify_name like concat('%',#{name},'%')
  520. </if>
  521. <if test="startDate != null and startDate != ''">
  522. and a.transfer_time &gt; #{startDate}
  523. </if>
  524. <if test="endDate != null and endDate != ''">
  525. and a.transfer_time &lt; #{endDate}
  526. </if>
  527. <if test="province != null">
  528. and b.location_province = #{province,jdbcType=INTEGER}
  529. </if>
  530. <if test="city != null">
  531. and b.location_city = #{city,jdbcType=INTEGER}
  532. </if>
  533. <if test="area != null">
  534. and b.location_area = #{area,jdbcType=INTEGER}
  535. </if>
  536. <if test="page_sql != null">
  537. ${page_sql}
  538. </if>
  539. </select>
  540. <select id="selectPublicOrganizationCustomerCount" resultType="java.lang.Integer">
  541. select
  542. count(0)
  543. from
  544. user a
  545. inner join organization_identity b on a.id = b.uid
  546. left join district_glossory dg1 on b.location_province = dg1.id
  547. left join district_glossory dg2 on b.location_city = dg2.id
  548. left join district_glossory dg3 on b.location_area = dg3.id
  549. where
  550. a.type = 1
  551. and a.share_type = 1
  552. and a.status != 1
  553. <if test="aid != null and aid !=''">
  554. and a..aid = #{aid,jdbcType=VARCHAR}
  555. </if>
  556. <if test="name != null and name != ''">
  557. and a.identify_name like concat('%',#{name},'%')
  558. </if>
  559. <if test="startDate != null and startDate != ''">
  560. and a.transfer_time &gt; #{startDate}
  561. </if>
  562. <if test="endDate != null and endDate != ''">
  563. and a.transfer_time &lt; #{endDate}
  564. </if>
  565. <if test="province != null">
  566. and b.location_province = #{province,jdbcType=INTEGER}
  567. </if>
  568. <if test="city != null">
  569. and b.location_city = #{city,jdbcType=INTEGER}
  570. </if>
  571. <if test="area != null">
  572. and b.location_area = #{area,jdbcType=INTEGER}
  573. </if>
  574. </select>
  575. <select id="selectSignOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  576. select
  577. t0.uid as uid,
  578. date_format(t3.last_sign_time,'%Y-%m-%d %H:%I:%S') as lastSignTime,
  579. t1.last_follow_time as lastFollowTime,
  580. t2.society_tag as societyTag,
  581. t2.identify_name as name,
  582. t2.share_type as shareType,
  583. t2.transfer_time as transferTime,
  584. dg1.name as province,
  585. dg2.name as city,
  586. dg3.name as area,
  587. b.contacts,
  588. b.contact_mobile as contactMobile,
  589. c.name as industry,
  590. d.name as adminName
  591. from
  592. (select uid,aid,max(lock_time) as update_time
  593. from user_lock_release
  594. where type=1 and status=0 and aid= #{aid,jdbcType=VARCHAR}
  595. group by uid)t0
  596. left join
  597. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid,jdbcType=VARCHAR} group by uid)t1
  598. on t0.uid = t1.uid
  599. inner join
  600. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 1)t2
  601. on t0.uid = t2.id
  602. left join (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid,jdbcType=VARCHAR} group by uid)t3
  603. on t0.uid = t3.uid
  604. left join organization_identity b on t0.uid = b.uid
  605. left join district_glossory dg1 on b.location_province = dg1.id
  606. left join district_glossory dg2 on b.location_city = dg2.id
  607. left join district_glossory dg3 on b.location_area = dg3.id
  608. left join industry_category c on b.industry = c.id
  609. left join admin d on t2.aid = d.id where 1 = 1
  610. <if test="name != null and name != ''">
  611. and t2.identify_name like concat('%',#{name},'%')
  612. </if>
  613. <if test="shareType != null">
  614. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  615. </if>
  616. <if test="startDate != null and startDate != ''">
  617. and t2.transfer_time &gt; #{startDate}
  618. </if>
  619. <if test="endDate != null and endDate != ''">
  620. and t2.transfer_time &lt; #{endDate}
  621. </if>
  622. <if test="province != null">
  623. and b.location_province = #{province,jdbcType=INTEGER}
  624. </if>
  625. <if test="city != null">
  626. and b.location_city = #{city,jdbcType=INTEGER}
  627. </if>
  628. <if test="area != null">
  629. and b.location_area = #{area,jdbcType=INTEGER}
  630. </if>
  631. order by t1.last_follow_time desc
  632. <if test="page_sql != null">
  633. ${page_sql}
  634. </if>
  635. </select>
  636. <select id="selectSignOrganizationCustomerCount" resultType="java.lang.Integer">
  637. select
  638. count(0)
  639. from
  640. (select uid,aid,max(lock_time) as update_time
  641. from user_lock_release
  642. where type=1 and status=0 and aid= #{aid,jdbcType=VARCHAR}
  643. group by uid)t0
  644. inner join
  645. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 1)t2
  646. on t0.uid = t2.id
  647. left join organization_identity b on t0.uid = b.uid where 1 = 1
  648. <if test="name != null and name != ''">
  649. and t2.identify_name like concat('%',#{name},'%')
  650. </if>
  651. <if test="shareType != null">
  652. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  653. </if>
  654. <if test="startDate != null and startDate != ''">
  655. and t2.transfer_time &gt; #{startDate}
  656. </if>
  657. <if test="endDate != null and endDate != ''">
  658. and t2.transfer_time &lt; #{endDate}
  659. </if>
  660. <if test="province != null">
  661. and b.location_province = #{province,jdbcType=INTEGER}
  662. </if>
  663. <if test="city != null">
  664. and b.location_city = #{city,jdbcType=INTEGER}
  665. </if>
  666. <if test="area != null">
  667. and b.location_area = #{area,jdbcType=INTEGER}
  668. </if>
  669. </select>
  670. <select id="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  671. select id,identify_name as name from user where identify_name like
  672. concat('%',#{identifyName},'%') and status <![CDATA[!= ]]> 1 and audit_status = 1
  673. </select>
  674. <select id="judgeCustomerByName" resultType="java.lang.Integer">
  675. select count(0) from user where identify_name = #{identifyName,jdbcType=VARCHAR}
  676. and status <![CDATA[!= ]]> 1
  677. </select>
  678. <select id="findOrganizationCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOrganizationDetailBo">
  679. select
  680. a.id as uid,
  681. a.society_tag as societyTag,
  682. a.company_logo_url as companyLogoUrl,
  683. a.introduction,
  684. a.identify_name as identifyName,
  685. b.industry,
  686. b.location_province as locationProvince,
  687. b.location_city as locationCity,
  688. b.location_area as locationArea,
  689. b.postal_address as postalAddress,
  690. b.contacts_fixed_tel as contactsFixedTel,
  691. b.contacts_fax as contactsFax,
  692. b.registered_capital registeredCapital,
  693. b.enterprise_scale as enterpriseScale,
  694. b.legal_person as legalPerson,
  695. b.legal_person_id_card as legalPersonIdCard,
  696. b.legal_person_tel as legalPersonTel,
  697. b.legal_person_email as legalPersonEmail,
  698. b.org_code as orgCode,
  699. b.org_code_url as orgCodeUrl,
  700. b.business_scope as businessScope,
  701. b.id,
  702. b.contacts,
  703. b.contact_mobile as contactMobile,
  704. b.licence_number as licenceNumber,
  705. a.aid as aid,
  706. d.name as adminName,
  707. a.information_maintainer as informationMaintainer,
  708. c.name as informationMaintainerName,
  709. a.core_technology as coreTechnology,
  710. a. accomplish_situation as accomplishSituation,
  711. a.intellectual_property as intellectualProperty,
  712. b.year_sales_amount as yearSalesAmount,
  713. b.last_year_research_amount as lastYearResearchAmount,
  714. b.assets,
  715. b.qualification,
  716. b.cooperation_situation as cooperationSituation,
  717. a.credit_rating as creditRating,
  718. e.poject_application_url as pojectApplicationUrl
  719. from
  720. user a inner join organization_identity b on a.id = b.uid
  721. left join admin d on d.id = a.aid
  722. left join admin c on c.id = a.information_maintainer
  723. left join organization_application_info e on a.id=e.uid
  724. where
  725. a.id = #{uid,jdbcType=VARCHAR}
  726. </select>
  727. <select id="findPersonalCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerPersonalDetailBo">
  728. select
  729. a.id as uid,
  730. a.identify_name as identifyName,
  731. a.society_tag as societyTag,
  732. a.head_portrait_url as headPortraitUrl,
  733. a.introduction,
  734. b.id,
  735. b.industry,
  736. b.sex,
  737. b.date_of_birth_year as dateOfBirthYear,
  738. b.date_of_birth_month as dateOfBirthMonth,
  739. b.id_number as idNumber,
  740. b.province,
  741. b.city,
  742. b.area,
  743. b.positive_id_url as positiveIdUrl,
  744. b.opposite_id_url as oppositeIdUrl,
  745. b.postal_address as postalAddress,
  746. b.contact_mobile as contactMobile,
  747. b.fixed_tel as fixedTel,
  748. b.email,
  749. b.expert,
  750. b.international,
  751. b.contacts,
  752. b.contact_mobile as contactMobile,
  753. b.qq,
  754. b.professional_title as professionalTitle,
  755. b.work_unit as workUnit,
  756. b.education,
  757. b.major_category as majorCategory,
  758. b.qualification,
  759. b.audit_status as auditStatus,
  760. b.graduate_school as graduateSchool,
  761. b.consultation_price as consultationPrice,
  762. b.expert_audit as expertAudit,
  763. b.release_status as releaseStatus,
  764. a.aid as aid,d.name as adminName
  765. from
  766. user a inner join user_identity b on
  767. a.id = b.uid
  768. left join admin d on d.id = a.aid
  769. where
  770. a.id = #{uid,jdbcType=VARCHAR}
  771. </select>
  772. <select id="selectFollowHistoryList" resultType="com.goafanti.customer.bo.FollowListBo">
  773. select
  774. a.id as followId,
  775. a.aid,
  776. a.create_time as followTime,
  777. a.contact_type as contactType,
  778. a.result,
  779. b.identify_name as identifyName,
  780. c.name as contacts,
  781. c.mobile as contactMobile,
  782. d.name as adminName
  783. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  784. ,e.id as ufbId,e.follow_situation as followSituation,e.customer_status as customerStatus
  785. </if>
  786. from user_follow a
  787. left join user b on a.uid = b.id
  788. left join organization_contact_book c on a.ocb_id = c.id
  789. left join admin d on a.aid = d.id
  790. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  791. inner join user_follow_business e on a.id = e.follow_id
  792. </if>
  793. where a.effective = 0
  794. <if test="uid != null and uid != ''">
  795. and a.uid = #{uid,jdbcType=VARCHAR}
  796. </if>
  797. <if test="aid != null and aid != ''">
  798. and a.aid = #{aid,jdbcType=VARCHAR}
  799. </if>
  800. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  801. and e.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  802. </if>
  803. <if test="page_sql != null">
  804. ${page_sql}
  805. </if>
  806. </select>
  807. <select id="selectFollowHistoryCount" resultType="java.lang.Integer">
  808. select
  809. count(0)
  810. from user_follow a
  811. left join user b on a.uid = b.id
  812. left join organization_contact_book c on a.ocb_id = c.id
  813. left join admin d on a.aid = d.id
  814. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  815. inner join user_follow_business e on a.id = e.follow_id
  816. </if>
  817. where a.effective = 0
  818. <if test="uid != null and uid != ''">
  819. and a.uid = #{uid,jdbcType=VARCHAR}
  820. </if>
  821. <if test="aid != null and aid != ''">
  822. and a.aid = #{aid,jdbcType=VARCHAR}
  823. </if>
  824. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  825. and e.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  826. </if>
  827. </select>
  828. <select id="findUserAccountDetail" parameterType="java.lang.String" resultType="com.goafanti.common.model.User">
  829. select
  830. id,
  831. mobile,
  832. nickname,
  833. create_time as createTime,
  834. type,
  835. source,
  836. email,
  837. identify_name as identifyName,
  838. status
  839. from
  840. user
  841. where id = #{uid,jdbcType=VARCHAR}
  842. </select>
  843. <select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  844. select id,name,mobile,email,qq,wechat,department,position,major from organization_contact_book
  845. where uid = #{uid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR}
  846. </select>
  847. <select id="findAllContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  848. select id,name,mobile,major,sex,department,position,wechat,qq from organization_contact_book
  849. where uid = #{uid,jdbcType=VARCHAR}
  850. </select>
  851. <select id="findFollowById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.FollowBusinessBo">
  852. select
  853. a.id as followId,
  854. a.uid,
  855. a.ocb_id as ocbId,
  856. a.contact_type as contactType,
  857. a.result,
  858. a.create_time as followTime,
  859. b.identify_name as identifyName,
  860. c.name as contacts,
  861. c.mobile as contactMobile,
  862. d.name as adminName
  863. from
  864. user_follow a
  865. left join user b on a.uid = b.id
  866. left join organization_contact_book c on a.ocb_id = c.id
  867. left join admin d on a.aid = d.id
  868. where a.id = #{followId,jdbcType=VARCHAR}
  869. </select>
  870. <select id="customerStatisticsList" resultType="com.goafanti.customer.bo.StatisticBo">
  871. select a.*,b.name as adminName,c.name as departmentName from (
  872. select
  873. aid,
  874. sum(case when customer_status = 0 then 1 else 0 end) as newNo, <!-- 新客户 -->
  875. sum(case when customer_status = 1 then 1 else 0 end) as intentionNo, <!-- 意向客户 -->
  876. sum(case when customer_status = 2 then 1 else 0 end) as pointNo, <!-- 重点客户 -->
  877. sum(case when customer_status = 3 then 1 else 0 end) as interviewNo, <!-- 面谈客户 -->
  878. sum(case when customer_status = 4 then 1 else 0 end) as signNo, <!-- 签单客户 -->
  879. sum(case when customer_status = 5 then 1 else 0 end) as refuseNo, <!-- 拒绝客户 -->
  880. sum(case when customer_status = 6 then 1 else 0 end) as stopNo <!-- 停止跟进 -->
  881. from user_business where 1=1
  882. <if test="sDate != null">
  883. and create_time &gt; #{sDate,jdbcType=DATE}
  884. </if>
  885. <if test="eDate != null">
  886. and create_time &lt; #{eDate,jdbcType=DATE}
  887. </if>
  888. <if test="businessGlossoryId != null">
  889. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  890. </if>
  891. group by aid
  892. )a
  893. left join admin b on a.aid = b.id
  894. left join department c on b.department_id = c.id
  895. <if test="depNo != null">
  896. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  897. </if>
  898. <if test="page_sql != null">
  899. ${page_sql}
  900. </if>
  901. </select>
  902. <select id="customerStatisticsCount" resultType="java.lang.Integer">
  903. select count(0) from (
  904. select
  905. aid
  906. from user_business where 1=1
  907. <if test="sDate != null">
  908. and create_time &gt; #{sDate,jdbcType=DATE}
  909. </if>
  910. <if test="eDate != null">
  911. and create_time &lt; #{eDate,jdbcType=DATE}
  912. </if>
  913. <if test="businessGlossoryId != null">
  914. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  915. </if>
  916. group by aid
  917. )a
  918. left join admin b on a.aid = b.id
  919. left join department c on b.department_id = c.id
  920. <if test="depNo !=null">
  921. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  922. </if>
  923. </select>
  924. <select id="businessStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  925. select a.*,b.name as adminName,c.name as departmentName from (
  926. select
  927. aid,
  928. sum(case when follow_situation = 0 then 1 else 0 end) as sendMaterialNo, <!-- 已发项目介绍资料 -->
  929. sum(case when follow_situation = 1 then 1 else 0 end) as interviewNo, <!-- 已约面谈 -->
  930. sum(case when follow_situation = 2 then 1 else 0 end) as sendProspectusNo, <!-- 已发合同计划书 -->
  931. sum(case when follow_situation = 3 then 1 else 0 end) as quoteNo, <!-- 已报价 -->
  932. sum(case when follow_situation = 4 then 1 else 0 end) as sendContractNo, <!-- 已发合同 -->
  933. sum(case when follow_situation = 5 then 1 else 0 end) as signContractNo, <!-- 已签合同 -->
  934. sum(case when follow_situation = 6 then 1 else 0 end) as onVisaNo, <!-- 面谈中 -->
  935. sum(case when follow_situation = 7 then 1 else 0 end) as visaNo <!-- 已面签 -->
  936. from user_business where 1=1
  937. <if test="sDate != null">
  938. and create_time &gt; #{sDate,jdbcType=DATE}
  939. </if>
  940. <if test="eDate != null">
  941. and create_time &lt; #{eDate,jdbcType=DATE}
  942. </if>
  943. <if test="businessGlossoryId != null">
  944. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  945. </if>
  946. group by aid
  947. )a
  948. left join admin b on a.aid = b.id
  949. left join department c on b.department_id = c.id
  950. <if test="depNo !=null">
  951. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  952. </if>
  953. <if test="page_sql != null">
  954. ${page_sql}
  955. </if>
  956. </select>
  957. <select id="businessStatisticCount" resultType="java.lang.Integer">
  958. select count(0) from (
  959. select
  960. aid
  961. from user_business where 1=1
  962. <if test="sDate != null">
  963. and create_time &gt; #{sDate,jdbcType=DATE}
  964. </if>
  965. <if test="eDate != null">
  966. and create_time &lt; #{eDate,jdbcType=DATE}
  967. </if>
  968. <if test="businessGlossoryId != null">
  969. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  970. </if>
  971. group by aid
  972. )a
  973. left join admin b on a.aid = b.id
  974. left join department c on b.department_id = c.id
  975. <if test="depNo !=null">
  976. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  977. </if>
  978. </select>
  979. <select id="followStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  980. select x.*,b.name as adminName,c.name as departmentName,y.* from (
  981. select
  982. count(0) as followNo,
  983. aid,
  984. sum(case when contact_type = 0 then 1 else 0 end) as visitNo, <!-- 外出 -->
  985. sum(case when contact_type = 1 then 1 else 0 end) as telNo, <!-- 电话 -->
  986. sum(case when contact_type = 2 then 1 else 0 end) as qqNo, <!-- QQ -->
  987. sum(case when contact_type = 3 then 1 else 0 end) as wxNo, <!-- 微信 -->
  988. sum(case when contact_type = 4 then 1 else 0 end) as emailNo, <!-- 邮件 -->
  989. sum(case when contact_type = 5 then 1 else 0 end) as letterNo <!-- 书信 -->
  990. from user_follow where 1=1
  991. <if test="sDate != null">
  992. and create_time &gt; #{sDate,jdbcType=DATE}
  993. </if>
  994. <if test="eDate != null">
  995. and create_time &lt; #{eDate,jdbcType=DATE}
  996. </if>
  997. group by aid
  998. )x
  999. left join admin b on x.aid = b.id
  1000. left join department c on b.department_id = c.id
  1001. left join
  1002. (
  1003. select
  1004. count( 0 ) as customerNo,
  1005. aid
  1006. from
  1007. (
  1008. select
  1009. aid,
  1010. uid
  1011. from
  1012. user_follow
  1013. group by
  1014. aid,
  1015. uid
  1016. ) a
  1017. group by
  1018. aid
  1019. )y on x.aid = y.aid
  1020. <if test="depNo !=null">
  1021. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  1022. </if>
  1023. </select>
  1024. <select id="followStatisticCount" resultType="java.lang.Integer">
  1025. select count(0) from (
  1026. select
  1027. aid
  1028. from user_follow where 1=1
  1029. <if test="sDate != null">
  1030. and create_time &gt; #{sDate,jdbcType=DATE}
  1031. </if>
  1032. <if test="sDate != null">
  1033. and create_time &lt; #{eDate,jdbcType=DATE}
  1034. </if>
  1035. group by aid
  1036. )x
  1037. left join admin b on x.aid = b.id
  1038. left join department c on b.department_id = c.id
  1039. <if test="depNo !=null">
  1040. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  1041. </if>
  1042. </select>
  1043. <select id="findBusinessByFollowId" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.BusinessListBo">
  1044. select
  1045. a.id as ufbId,
  1046. a.follow_situation as followSituation,
  1047. a.customer_status as customerStatus,
  1048. a.remarks,
  1049. a.business_project_id as businessProjectId,
  1050. b.bname as businessProjectName,
  1051. c.cname as businessVarietiesName
  1052. from
  1053. user_follow_business a
  1054. left join business_project b on a.business_project_id = b.id
  1055. left join business_category c on b.cid = c.id
  1056. where
  1057. a.follow_id = #{followId,jdbcType=VARCHAR}
  1058. </select>
  1059. <select id="selectBusinessList" resultType="com.goafanti.customer.bo.BusinessListBo">
  1060. select
  1061. c.bname as businessName,
  1062. b.identify_name as identifyName,
  1063. a.id as businessId,
  1064. a.business_project_id as businessProjectId,
  1065. a.create_time as createTime,
  1066. a.update_time as updateTime,
  1067. a.follow_situation as followSituation,
  1068. a.customer_status as customerStatus,
  1069. d.name as adminName
  1070. from
  1071. user_business a inner join user b on
  1072. a.uid = b.id left join business_project c on
  1073. a.business_project_id = c.id left join admin d on
  1074. a.aid = d.id
  1075. where 1 = 1
  1076. <if test="aid != null and aid != ''">
  1077. and a.aid = #{aid,jdbcType=VARCHAR}
  1078. </if>
  1079. <if test="uid != null and uid !=''">
  1080. and a.uid = #{uid,jdbcType=VARCHAR}
  1081. </if>
  1082. <if test="businessProjectId !=null and businessProjectId != ''">
  1083. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1084. </if>
  1085. <if test="identifyName != null and identifyName != ''">
  1086. and b.identify_name like concat('%', #{identifyName},'%')
  1087. </if>
  1088. <if test="followSituation != null">
  1089. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1090. </if>
  1091. <if test="customerStatus != null">
  1092. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1093. </if>
  1094. <if test="adminName != null and adminName != ''">
  1095. and d.name = #{adminName,jdbcType=VARCHAR}
  1096. </if>
  1097. <if test="startDate != null and startDate != ''">
  1098. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1099. </if>
  1100. <if test="endDate != null and endDate != ''">
  1101. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1102. </if>
  1103. order by a.create_time desc
  1104. <if test="page_sql != null">
  1105. ${page_sql}
  1106. </if>
  1107. </select>
  1108. <select id="selectBusinessCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
  1109. select
  1110. count(0)
  1111. from
  1112. user_business a inner join user b on
  1113. a.uid = b.id left join business_project c on
  1114. a.business_project_id = c.id left join admin d on
  1115. a.aid = d.id
  1116. where 1 = 1
  1117. <if test="aid != null and aid != ''">
  1118. and a.aid = #{aid,jdbcType=VARCHAR}
  1119. </if>
  1120. <if test="uid != null and uid !=''">
  1121. and a.uid = #{uid,jdbcType=VARCHAR}
  1122. </if>
  1123. <if test="businessProjectId !=null and businessProjectId != ''">
  1124. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1125. </if>
  1126. <if test="identifyName != null and identifyName != ''">
  1127. and b.identify_name like concat('%', #{identifyName},'%')
  1128. </if>
  1129. <if test="followSituation != null">
  1130. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1131. </if>
  1132. <if test="customerStatus != null">
  1133. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1134. </if>
  1135. <if test="adminName != null and adminName != ''">
  1136. and d.name = #{adminName,jdbcType=VARCHAR}
  1137. </if>
  1138. <if test="startDate != null and startDate != ''">
  1139. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1140. </if>
  1141. <if test="endDate != null and endDate != ''">
  1142. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1143. </if>
  1144. </select>
  1145. <select id="selectBusinessManageList" resultType="com.goafanti.customer.bo.BusinessListBo">
  1146. select
  1147. c.name as businessName,
  1148. b.identify_name as identifyName,
  1149. a.id as businessId,
  1150. a.create_time as createTime,
  1151. a.update_time as updateTime,
  1152. a.follow_situation as followSituation,
  1153. a.customer_status as customerStatus,
  1154. d.name as adminName
  1155. from
  1156. user_business a inner join user b on
  1157. a.uid = b.id left join business_glossory c on
  1158. a.business_project_id = c.id left join admin d on
  1159. a.aid = d.id
  1160. left join department dm on dm.id = d.department_id
  1161. where 1 = 1
  1162. <if test="aid != null and aid != ''">
  1163. and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1164. </if>
  1165. <if test="uid != null and uid !=''">
  1166. and a.uid = #{uid,jdbcType=VARCHAR}
  1167. </if>
  1168. <if test="businessProjectId !=null and businessProjectId != ''">
  1169. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1170. </if>
  1171. <if test="identifyName != null and identifyName != ''">
  1172. and b.identify_name like concat('%', #{identifyName},'%')
  1173. </if>
  1174. <if test="followSituation != null">
  1175. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1176. </if>
  1177. <if test="customerStatus != null">
  1178. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1179. </if>
  1180. <if test="adminName != null and adminName != ''">
  1181. and d.name = #{adminName,jdbcType=VARCHAR}
  1182. </if>
  1183. <if test="startDate != null and startDate != ''">
  1184. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1185. </if>
  1186. <if test="endDate != null and endDate != ''">
  1187. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1188. </if>
  1189. order by a.create_time desc
  1190. <if test="page_sql != null">
  1191. ${page_sql}
  1192. </if>
  1193. </select>
  1194. <select id="selectBusinessManageCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
  1195. select
  1196. count(0)
  1197. from
  1198. user_business a inner join user b on
  1199. a.uid = b.id left join business_glossory c on
  1200. a.business_project_id = c.id left join admin d on
  1201. a.aid = d.id
  1202. left join department dm on dm.id = d.department_id
  1203. where 1 = 1
  1204. <if test="aid != null and aid != ''">
  1205. and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1206. </if>
  1207. <if test="uid != null and uid !=''">
  1208. and a.uid = #{uid,jdbcType=VARCHAR}
  1209. </if>
  1210. <if test="businessProjectId !=null and businessProjectId != ''">
  1211. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1212. </if>
  1213. <if test="identifyName != null and identifyName != ''">
  1214. and b.identify_name like concat('%', #{identifyName},'%')
  1215. </if>
  1216. <if test="followSituation != null">
  1217. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1218. </if>
  1219. <if test="customerStatus != null">
  1220. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1221. </if>
  1222. <if test="adminName != null and adminName != ''">
  1223. and d.name = #{adminName,jdbcType=VARCHAR}
  1224. </if>
  1225. <if test="startDate != null and startDate != ''">
  1226. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1227. </if>
  1228. <if test="endDate != null and endDate != ''">
  1229. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1230. </if>
  1231. </select>
  1232. <select id="selectManagePersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1233. select
  1234. a.id as uid,
  1235. a.type,
  1236. a.status,
  1237. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  1238. a.business_audit as businessAudit,
  1239. a.current_member_status as currentMemberStatus,
  1240. a.identify_name as name,
  1241. a.lvl,a.is_member as isMember,
  1242. a.society_tag as societyTag,
  1243. a.share_type as shareType,
  1244. b.contacts,
  1245. b.contact_mobile as contactMobile,
  1246. b.international,
  1247. b.expert,
  1248. b.audit_status as auditStatus,
  1249. dg1.name as province,
  1250. dg2.name as city,
  1251. dg3.name as area,
  1252. c.name as industry,
  1253. d.name as adminName,
  1254. b.expert_audit as expertAudit,
  1255. b.release_status as releaseStatus
  1256. from user a inner join user_identity b on a.id = b.uid
  1257. left join district_glossory dg1 on b.province = dg1.id
  1258. left join district_glossory dg2 on b.city = dg2.id
  1259. left join district_glossory dg3 on b.area = dg3.id
  1260. left join industry_category c on b.industry = c.id
  1261. left join admin d on a.aid = d.id
  1262. LEFT JOIN department dm on dm.id = d.department_id
  1263. where a.type = 0 and a.status != 1 and a.audit_status = 1
  1264. and a.share_type =0
  1265. <if test="aid != null and aid !=''">
  1266. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1267. </if>
  1268. <if test="name != null and name != ''">
  1269. and a.identify_name like concat('%',#{name},'%')
  1270. </if>
  1271. <if test="shareType != null">
  1272. and a.share_type = #{shareType,jdbcType=INTEGER}
  1273. </if>
  1274. <if test="status != null">
  1275. and a.status = #{status,jdbcType=INTEGER}
  1276. </if>
  1277. <if test="businessAudit != null">
  1278. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  1279. </if>
  1280. <if test="isMember != null">
  1281. and a.is_member = #{isMember,jdbcType=INTEGER}
  1282. </if>
  1283. <if test="lvl != null">
  1284. and a.lvl = #{lvl,jdbcType=INTEGER}
  1285. </if>
  1286. <if test="currentMemberStatus != null">
  1287. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  1288. </if>
  1289. <if test="societyTag != null and societyTag != ''">
  1290. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1291. </if>
  1292. <if test="startDate != null and startDate != ''">
  1293. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1294. </if>
  1295. <if test="endDate != null and endDate != ''">
  1296. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1297. </if>
  1298. <if test="province != null">
  1299. and b.province = #{province,jdbcType=INTEGER}
  1300. </if>
  1301. <if test="city != null">
  1302. and b.city = #{city,jdbcType=INTEGER}
  1303. </if>
  1304. <if test="area != null">
  1305. and b.area = #{area,jdbcType=INTEGER}
  1306. </if>
  1307. <if test="industry != null">
  1308. and b.industry = #{industry,jdbcType=INTEGER}
  1309. </if>
  1310. <if test="expert != null">
  1311. and b.expert = #{expert,jdbcType=INTEGER}
  1312. </if>
  1313. <if test="international != null">
  1314. and b.international = #{international,jdbcType=INTEGER}
  1315. </if>
  1316. <if test="auditStatus != null">
  1317. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  1318. </if>
  1319. <if test="page_sql != null">
  1320. ${page_sql}
  1321. </if>
  1322. </select>
  1323. <select id="selectManagePersonalCustomerCount" resultType="java.lang.Integer">
  1324. select count(0)
  1325. from user a inner join user_identity b on a.id = b.uid
  1326. left join admin d on a.aid = d.id
  1327. LEFT JOIN department dm on dm.id = d.department_id
  1328. where a.type = 0 and a.status != 1 and a.audit_status = 1
  1329. <if test="aid != null and aid !=''">
  1330. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1331. </if>
  1332. <if test="name != null and name != ''">
  1333. and a.identify_name like concat('%',#{name},'%')
  1334. </if>
  1335. <if test="shareType != null">
  1336. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1337. </if>
  1338. <if test="status != null">
  1339. and a.status = #{status,jdbcType=INTEGER}
  1340. </if>
  1341. <if test="businessAudit != null">
  1342. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  1343. </if>
  1344. <if test="isMember != null">
  1345. and a.is_member = #{isMember,jdbcType=INTEGER}
  1346. </if>
  1347. <if test="lvl != null">
  1348. and a.lvl = #{lvl,jdbcType=INTEGER}
  1349. </if>
  1350. <if test="currentMemberStatus != null">
  1351. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  1352. </if>
  1353. <if test="societyTag != null and societyTag != ''">
  1354. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1355. </if>
  1356. <if test="startDate != null and startDate != ''">
  1357. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1358. </if>
  1359. <if test="endDate != null and endDate != ''">
  1360. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1361. </if>
  1362. <if test="province != null">
  1363. and b.province = #{province,jdbcType=INTEGER}
  1364. </if>
  1365. <if test="city != null">
  1366. and b.city = #{city,jdbcType=INTEGER}
  1367. </if>
  1368. <if test="area != null">
  1369. and b.area = #{area,jdbcType=INTEGER}
  1370. </if>
  1371. <if test="industry != null">
  1372. and b.industry = #{industry,jdbcType=INTEGER}
  1373. </if>
  1374. <if test="expert != null">
  1375. and b.expert = #{expert,jdbcType=INTEGER}
  1376. </if>
  1377. <if test="international != null">
  1378. and b.international = #{international,jdbcType=INTEGER}
  1379. </if>
  1380. <if test="auditStatus != null">
  1381. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  1382. </if>
  1383. </select>
  1384. <select id="selectManageOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1385. select
  1386. a.id as uid,
  1387. a.type,
  1388. a.status,
  1389. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  1390. a.identify_name as name,
  1391. a.society_tag as societyTag,
  1392. share_type as shareType,
  1393. b.contacts,
  1394. b.contact_mobile as contactMobile,
  1395. dg1.name as province,
  1396. dg2.name as city,
  1397. dg3.name as area,
  1398. c.name as industry,
  1399. d.name as adminName
  1400. from user a inner join organization_identity b on a.id = b.uid
  1401. left join district_glossory dg1 on b.location_province = dg1.id
  1402. left join district_glossory dg2 on b.location_city = dg2.id
  1403. left join district_glossory dg3 on b.location_area = dg3.id
  1404. left join industry_category c on b.industry = c.id
  1405. left join admin d on a.aid = d.id
  1406. LEFT JOIN department dm on dm.id = d.department_id
  1407. where a.type = 1 and a.status != 1 and a.audit_status = 1
  1408. <if test="aid != null and aid !=''">
  1409. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1410. </if>
  1411. <if test="name != null and name != ''">
  1412. and a.identify_name like concat('%',#{name},'%')
  1413. </if>
  1414. <if test="shareType != null">
  1415. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1416. </if>
  1417. <if test="status != null">
  1418. and a.status = #{status,jdbcType=INTEGER}
  1419. </if>
  1420. <if test="societyTag != null and societyTag != ''">
  1421. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1422. </if>
  1423. <if test="startDate != null and startDate != ''">
  1424. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1425. </if>
  1426. <if test="endDate != null and endDate != ''">
  1427. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1428. </if>
  1429. <if test="province != null">
  1430. and b.location_province = #{province,jdbcType=INTEGER}
  1431. </if>
  1432. <if test="city != null">
  1433. and b.location_city = #{city,jdbcType=INTEGER}
  1434. </if>
  1435. <if test="area != null">
  1436. and b.location_area = #{area,jdbcType=INTEGER}
  1437. </if>
  1438. <if test="page_sql != null">
  1439. ${page_sql}
  1440. </if>
  1441. </select>
  1442. <select id="selectManageOrganizationCustomerCount" resultType="java.lang.Integer">
  1443. select
  1444. count(0)
  1445. from user a inner join organization_identity b on a.id = b.uid
  1446. left join admin d on a.aid = d.id
  1447. LEFT JOIN department dm on dm.id = d.department_id
  1448. where a.type = 1 and a.status != 1 and a.audit_status = 1
  1449. <if test="aid != null and aid !=''">
  1450. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1451. </if>
  1452. <if test="name != null and name != ''">
  1453. and a.identify_name like concat('%',#{name},'%')
  1454. </if>
  1455. <if test="shareType != null">
  1456. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1457. </if>
  1458. <if test="status != null">
  1459. and a.status = #{status,jdbcType=INTEGER}
  1460. </if>
  1461. <if test="societyTag != null and societyTag != ''">
  1462. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1463. </if>
  1464. <if test="startDate != null and startDate != ''">
  1465. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1466. </if>
  1467. <if test="endDate != null and endDate != ''">
  1468. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1469. </if>
  1470. <if test="province != null">
  1471. and b.location_province = #{province,jdbcType=INTEGER}
  1472. </if>
  1473. <if test="city != null">
  1474. and b.location_city = #{city,jdbcType=INTEGER}
  1475. </if>
  1476. <if test="area != null">
  1477. and b.location_area = #{area,jdbcType=INTEGER}
  1478. </if>
  1479. </select>
  1480. <select id="findAdminName" resultType="com.goafanti.customer.bo.CustomerListOut">
  1481. select d.name as adminName,d.id as aid
  1482. from admin d left join department dm on dm.id = d.department_id
  1483. where d.department_id=(select department_id from admin where id=#{aid,jdbcType=INTEGER})
  1484. </select>
  1485. <select id="findEnteringAuditList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1486. 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
  1487. from user u left join admin a on u.aid=a.id
  1488. where u.audit_status=0 and u.status != 1 and u.share_type=0
  1489. <if test="aid != null and aid !=''">
  1490. and u.aid = #{aid,jdbcType=VARCHAR}
  1491. </if>
  1492. <if test="name != null and name != ''">
  1493. and u.nickname = #{name,jdbcType=VARCHAR}
  1494. </if>
  1495. <if test="adminName != null and adminName != ''">
  1496. and a.name = #{adminName,jdbcType=VARCHAR}
  1497. </if>
  1498. <if test="page_sql != null">
  1499. ${page_sql}
  1500. </if>
  1501. </select>
  1502. <select id="findEnteringAuditCount" resultType="java.lang.Integer">
  1503. select
  1504. count(0)
  1505. from user u left join admin a on u.aid=a.id
  1506. where u.audit_status=0 and u.status != 1 and u.share_type=0
  1507. <if test="aid != null and aid !=''">
  1508. and u.aid = #{aid,jdbcType=VARCHAR}
  1509. </if>
  1510. <if test="name != null and name != ''">
  1511. and u.nickname = #{name,jdbcType=VARCHAR}
  1512. </if>
  1513. <if test="adminName != null and adminName != ''">
  1514. and a.name = #{adminName,jdbcType=VARCHAR}
  1515. </if>
  1516. </select>
  1517. <select id="findEnteringAuditIsNoList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1518. select u.id as uid,u.nickname as name,u.mobile as contactMobile,a.name as adminName,u.create_time as createTime,
  1519. u.audit_status as auditStatus,u.audit_opinion as auditOpinion,u.society_tag as societyTag
  1520. from user u left join admin a on u.aid=a.id
  1521. where u.audit_status=2 and u.status != 1
  1522. <if test="aid != null and aid !=''">
  1523. and u.aid = #{aid,jdbcType=VARCHAR}
  1524. </if>
  1525. <if test="name != null and name != ''">
  1526. and u.nickname = #{name,jdbcType=VARCHAR}
  1527. </if>
  1528. <if test="adminName != null and adminName != ''">
  1529. and a.name = #{adminName,jdbcType=VARCHAR}
  1530. </if>
  1531. <if test="page_sql != null">
  1532. ${page_sql}
  1533. </if>
  1534. </select>
  1535. <select id="findEnteringAuditIsNoCount" resultType="java.lang.Integer">
  1536. select
  1537. count(0)
  1538. from user u left join admin a on u.aid=a.id
  1539. where u.audit_status=2 and u.status != 1
  1540. <if test="aid != null and aid !=''">
  1541. and u.aid = #{aid,jdbcType=VARCHAR}
  1542. </if>
  1543. <if test="name != null and name != ''">
  1544. and u.nickname = #{name,jdbcType=VARCHAR}
  1545. </if>
  1546. <if test="adminName != null and adminName != ''">
  1547. and a.name = #{adminName,jdbcType=VARCHAR}
  1548. </if>
  1549. </select>
  1550. <update id="updateRefusedCustomer" parameterType="map">
  1551. update user
  1552. set
  1553. nickname = #{nickname,jdbcType=VARCHAR},
  1554. mobile = #{mobile,jdbcType=VARCHAR},
  1555. society_tag = #{societyTag,jdbcType=VARCHAR},
  1556. audit_status=1
  1557. where id = #{id,jdbcType=VARCHAR}
  1558. </update>
  1559. <select id="selectLockedProject" resultType="com.goafanti.customer.bo.LockingReleaseBo">
  1560. select
  1561. a.id,
  1562. a.uid,
  1563. a.aid,
  1564. date_format( a.lock_time, '%Y-%m-%d %H:%i:%S' ) as lockTime,
  1565. a.business_project_id as businessProjectId,
  1566. b.bname as businessProjectName,
  1567. d.name as salesmanName
  1568. from
  1569. user_lock_release a left join business_project b on
  1570. a.business_project_id = b.id left join business_category c on
  1571. b.cid = c.id left join admin d on
  1572. a.aid = d.id
  1573. where 1 = 1
  1574. <if test="uid != null and uid != ''">
  1575. and a.uid = #{uid}
  1576. </if>
  1577. <if test="aid != null and aid != ''">
  1578. and a.aid = #{aid}
  1579. </if>
  1580. <if test="businessProjectId != null and businessProjectId != ''">
  1581. and a.business_project_id = #{businessProjectId}
  1582. </if>
  1583. <if test="type != null">
  1584. and a.type = #{type}
  1585. </if>
  1586. <if test="status != null">
  1587. and a.status = #{status}
  1588. </if>
  1589. </select>
  1590. <select id="selectPrivateCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  1591. select b.id,b.identify_name as name from
  1592. (select uid from user_lock_release where type = 0 and status = 0 and aid = #{aid} group by uid) a
  1593. inner join user b on a.uid = b.id
  1594. where b.status != 1 and b.identify_name like concat('%',#{name},'%')
  1595. </select>
  1596. <select id="selectSignedCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  1597. select b.id,b.identify_name as name from
  1598. (select uid from user_lock_release where type = 1 and status = 0 and aid = #{aid} group by uid) a
  1599. inner join user b on a.uid = b.id
  1600. where b.status != 1 and b.identify_name like concat('%',#{name},'%')
  1601. </select>
  1602. <update id="updateReleaseLock" parameterType="java.lang.String">
  1603. update user a,user_lock_release b set a.share_type = 1,a.transfer_time = #{time} where b.status=1 and a.id=b.uid
  1604. </update>
  1605. <select id="marketingStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
  1606. select
  1607. aid,
  1608. count(0) as yearFollowNo,
  1609. ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as yearVisitNo,
  1610. ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as yearTelNo
  1611. from user_follow where 1=1
  1612. and aid = #{id,jdbcType=VARCHAR}
  1613. and create_time &gt; #{dailyStart,jdbcType=VARCHAR}
  1614. and create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
  1615. GROUP BY aid
  1616. </select>
  1617. <select id="marketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
  1618. select
  1619. b.department_id,
  1620. count( 0 ) as yearFollowNo,
  1621. ifnull(
  1622. sum( case when a.contact_type = 0 then 1 else 0 end ),
  1623. 0
  1624. ) as yearVisitNo,
  1625. ifnull(
  1626. sum( case when a.contact_type = 1 then 1 else 0 end ),
  1627. 0
  1628. ) as yearTelNo
  1629. from user_follow a left join admin b on a.aid =b.id
  1630. where
  1631. 1 = 1
  1632. <if test="depId !=null">
  1633. and b.department_id = #{depId,jdbcType=VARCHAR}
  1634. </if>
  1635. and a.create_time &gt; #{dailyStart,jdbcType=VARCHAR}
  1636. and a.create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
  1637. GROUP BY b.department_id
  1638. </select>
  1639. <select id="countmarketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.CountMarketingStatisticsBo">
  1640. select
  1641. count( 0 ) as yearFollowNo,
  1642. ifnull(
  1643. sum( case when a.contact_type = 0 then 1 else 0 end ),
  1644. 0
  1645. ) as yearVisitNo,
  1646. ifnull(
  1647. sum( case when a.contact_type = 1 then 1 else 0 end ),
  1648. 0
  1649. ) as yearTelNo
  1650. from user_follow a left join admin b on a.aid =b.id
  1651. where
  1652. 1 = 1
  1653. <if test="depId !=null">
  1654. and b.department_id = #{depId,jdbcType=VARCHAR}
  1655. </if>
  1656. and a.create_time &gt; #{dailyStart,jdbcType=VARCHAR}
  1657. and a.create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
  1658. </select>
  1659. <select id="selectCustomerInformationList" resultType="com.goafanti.customer.bo.CustomerListIn">
  1660. select a.id,a.nickname as name,c.name as province,c1.name as city,c2.name as area,b.contacts,b.contact_mobile as contactMobile,
  1661. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,d.name as industry,a.credit_rating as creditRating,a.integrity as dataGrade
  1662. from user a left join organization_identity b
  1663. on a.id=b.uid left join district_glossory c
  1664. on b.location_province=c.id left join district_glossory c1
  1665. on b.location_city=c1.id left join district_glossory c2
  1666. on b.location_area=c2.id left join industry_category d on b.industry = d.id
  1667. <if test="follow !=null and follow!=''">
  1668. left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
  1669. </if>
  1670. where a.status=0
  1671. and a.information_maintainer = #{aid,jdbcType=VARCHAR}
  1672. <if test="type !=null and type!=''">
  1673. and a.`type`=#{type,jdbcType=VARCHAR}
  1674. </if>
  1675. <if test="follow ==0">
  1676. and (e.contact_type !=0 or e.contact_type is null)
  1677. </if>
  1678. <if test="follow ==1">
  1679. and e.contact_type=0
  1680. </if>
  1681. <if test="name!=null and name!=''">
  1682. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1683. </if>
  1684. <if test="province!=null and province!=''">
  1685. and b.location_province= #{province,jdbcType=VARCHAR}
  1686. </if>
  1687. <if test="city!=null and city!=''">
  1688. and b.location_city=#{city,jdbcType=VARCHAR}
  1689. </if>
  1690. <if test="area !=null and area !=''">
  1691. and b.location_area= #{area,jdbcType=VARCHAR}
  1692. </if>
  1693. <if test="startDate != null and startDate != ''">
  1694. and a.create_time &gt; #{startDate}
  1695. </if>
  1696. <if test="endDate != null and endDate != ''">
  1697. and a.create_time &lt; #{endDate}
  1698. </if>
  1699. <if test="dataGrade ==0">
  1700. and a.integrity !=1
  1701. </if>
  1702. <if test="dataGrade ==1">
  1703. and a.integrity =1
  1704. </if>
  1705. order by a.create_time desc,a.nickname desc
  1706. <if test="page_sql != null">
  1707. ${page_sql}
  1708. </if>
  1709. </select>
  1710. <select id="selectCustomerInformationCount" resultType="java.lang.Integer">
  1711. select count(0)
  1712. from user a left join organization_identity b
  1713. on a.id=b.uid
  1714. <if test="follow !=null and follow!=''">
  1715. left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
  1716. </if>
  1717. where a.status=0 and a.information_maintainer = #{aid,jdbcType=VARCHAR}
  1718. <if test="type !=null and type!=''">
  1719. and a.`type`=#{type,jdbcType=VARCHAR}
  1720. </if>
  1721. <if test="follow ==0">
  1722. and (e.contact_type !=0 or e.contact_type is null)
  1723. </if>
  1724. <if test="follow ==1">
  1725. and e.contact_type=0
  1726. </if>
  1727. <if test="name!=null and name!=''">
  1728. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1729. </if>
  1730. <if test="province!=null and province!=''">
  1731. and b.location_province= #{province,jdbcType=VARCHAR}
  1732. </if>
  1733. <if test="city!=null and city!=''">
  1734. and b.location_city=#{city,jdbcType=VARCHAR}
  1735. </if>
  1736. <if test="area !=null and area !=''">
  1737. and b.location_area= #{area,jdbcType=VARCHAR}
  1738. </if>
  1739. <if test="startDate != null and startDate != ''">
  1740. and a.create_time &gt; #{startDate}
  1741. </if>
  1742. <if test="endDate != null and endDate != ''">
  1743. and a.create_time &lt; #{endDate}
  1744. </if>
  1745. <if test="dataGrade ==0">
  1746. and a.integrity !=1
  1747. </if>
  1748. <if test="dataGrade ==1">
  1749. and a.integrity =1
  1750. </if>
  1751. </select>
  1752. <select id="selectDepCustomerInformationList" resultType="com.goafanti.customer.bo.CustomerListIn">
  1753. select x.id,
  1754. x.name,
  1755. x.province,
  1756. x.city,
  1757. x.area ,
  1758. x.contacts,
  1759. x.contact_mobile as contactMobile,
  1760. date_format( x.create_time, '%Y-%m-%d %H:%i:%S' ) as createTime,
  1761. x.industry as industry,
  1762. y.name as iname,
  1763. x.integrity as dataGrade,
  1764. x.credit_rating as creditRating
  1765. from(
  1766. select
  1767. a.id,
  1768. a.nickname as name,
  1769. c.name as province,
  1770. c1.name as city,
  1771. c2.name as area,
  1772. b.contacts,
  1773. b.contact_mobile,
  1774. a.create_time,
  1775. d.name as industry,
  1776. a.credit_rating ,
  1777. a.information_maintainer,
  1778. a.integrity
  1779. from
  1780. user a left join organization_identity b on
  1781. a.id = b.uid left join district_glossory c
  1782. on b.location_province=c.id left join district_glossory c1
  1783. on b.location_city=c1.id left join district_glossory c2
  1784. on b.location_area=c2.id left join industry_category d
  1785. on b.industry = d.id
  1786. where a.status=0
  1787. <if test="type !=null and type!=''">
  1788. and a.`type`=#{type,jdbcType=VARCHAR}
  1789. </if>
  1790. <if test="name!=null and name!=''">
  1791. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1792. </if>
  1793. <if test="province!=null and province!=''">
  1794. and b.location_province= #{province,jdbcType=VARCHAR}
  1795. </if>
  1796. <if test="city!=null and city!=''">
  1797. and b.location_city=#{city,jdbcType=VARCHAR}
  1798. </if>
  1799. <if test="area !=null and area !=''">
  1800. and b.location_area= #{area,jdbcType=VARCHAR}
  1801. </if>
  1802. <if test="startDate != null and startDate != ''">
  1803. and a.create_time &gt; #{startDate}
  1804. </if>
  1805. <if test="endDate != null and endDate != ''">
  1806. and a.create_time &lt; #{endDate}
  1807. </if>
  1808. <if test="dataGrade ==0">
  1809. and a.integrity !=1
  1810. </if>
  1811. <if test="dataGrade ==1">
  1812. and a.integrity =1
  1813. </if>
  1814. order by a.create_time,a.nickname desc
  1815. )x
  1816. inner join(
  1817. select id ,name from admin a
  1818. inner join (select department_id as depId from admin where id= #{aid,jdbcType=VARCHAR})b on a.department_id=b.depId
  1819. ) y on y.id = x.information_maintainer
  1820. <if test="page_sql != null">
  1821. ${page_sql}
  1822. </if>
  1823. </select>
  1824. <select id="selectDepCustomerInformationCount" resultType="java.lang.Integer">
  1825. select count(0)
  1826. from user a left join organization_identity b
  1827. on a.id=b.uid inner join (select id from admin a
  1828. inner join (select department_id as depId from admin where id= #{aid,jdbcType=VARCHAR} )b on a.department_id=b.depId) y
  1829. on y.id=a.information_maintainer
  1830. where 1=1 and a.status=0
  1831. <if test="type !=null and type!=''">
  1832. and a.`type`=#{type,jdbcType=VARCHAR}
  1833. </if>
  1834. <if test="name!=null and name!=''">
  1835. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1836. </if>
  1837. <if test="province!=null and province!=''">
  1838. and b.location_province= #{province,jdbcType=VARCHAR}
  1839. </if>
  1840. <if test="city!=null and city!=''">
  1841. and b.location_city=#{city,jdbcType=VARCHAR}
  1842. </if>
  1843. <if test="area !=null and area !=''">
  1844. and b.location_area= #{area,jdbcType=VARCHAR}
  1845. </if>
  1846. <if test="startDate != null and startDate != ''">
  1847. and a.create_time &gt; #{startDate}
  1848. </if>
  1849. <if test="endDate != null and endDate != ''">
  1850. and a.create_time &lt; #{endDate}
  1851. </if>
  1852. <if test="dataGrade ==0">
  1853. and a.integrity !=1
  1854. </if>
  1855. <if test="dataGrade ==1">
  1856. and a.integrity =1
  1857. </if>
  1858. </select>
  1859. <select id="checkCustomerInformation" resultType="java.lang.Integer">
  1860. select count(a.id)
  1861. from user a left join organization_identity b
  1862. on a.id=b.uid
  1863. where b.industry is not null
  1864. and b.business_scope is not null
  1865. and b.registered_capital is not null and b.registered_capital !=0
  1866. and b.location_province is not null and b.location_province !=0
  1867. and b.cooperation_situation is not null and b.cooperation_situation !=''
  1868. and b.qualification is not null and b.qualification !=''
  1869. and b.assets is not null and b.assets !=''
  1870. and b.last_year_research_amount is not null and b.last_year_research_amount !=''
  1871. and b.year_sales_amount is not null and b.year_sales_amount !=''
  1872. and a.core_technology is not null and a.core_technology !=''
  1873. and a.accomplish_situation is not null and a.accomplish_situation !=''
  1874. and a.credit_rating is not null and a.credit_rating !=''
  1875. and a.id=#{uid,jdbcType=VARCHAR}
  1876. </select>
  1877. <select id="userDataStatistics" resultType="com.goafanti.report.bo.userDataListBo">
  1878. select a.name ,c.name as depName,ifnull(d.count,0) as signUser,ifnull(e.count,0) as fullUser,
  1879. ifnull(f.count,0) as dayFullUser,ifnull(g.count,0) as dayNewUser,ifnull(h.count,0) as countUser,
  1880. ifnull(i.count,0) as signFullUser
  1881. from admin a inner join (select uid from user_role x
  1882. inner join(select id from `role` where role_name in ('营销员','营销经理','营销管理员')) y
  1883. on x.rid=y.id)b on a.id =b.uid left join department c on a.department_id=c.id
  1884. left join (select x.aid,count(1)as count from (select aid,uid from user_lock_release
  1885. where type=1 and status=0 group by aid,uid)x group by aid)d on a.id=d.aid
  1886. left join (select aid,count(1) as count from user where integrity=1 and type=1 and status=0 and share_type=0 group by aid) e on a.id=e.aid
  1887. left join (select aid,count(1) as count
  1888. from user where integrity=1 and type=1 and status=0 and share_type=0 and to_days(update_time)=to_days(now()) group by aid) f on a.id=f.aid
  1889. left join (select aid,count(1) as count
  1890. from user where type=1 and status=0 and share_type=0 and to_days(create_time)=to_days(now()) group by aid) g on a.id=g.aid
  1891. left join (select aid,count(1) as count
  1892. from user where type=1 and status=0 and share_type=0 group by aid) h on a.id=h.aid
  1893. left join (select x.aid,count(1)as count from (select x1.aid,x1.uid from user_lock_release x1
  1894. left join user y on x1.uid=y.id where x1.type=1
  1895. and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
  1896. where a.status='正常'
  1897. <if test="depId!=null and depId!=''">
  1898. and a.department_id= #{depId,jdbcType=VARCHAR}
  1899. </if>
  1900. </select>
  1901. <select id="userDataStatisticsCount" resultType="com.goafanti.report.bo.userDataListBo">
  1902. select sum(z.signUser) as signUser,sum(z.fullUser) as fullUser,sum(z.dayFullUser) as dayFullUser,
  1903. sum(z.dayNewUser) as dayNewUser,sum(z.countUser) as countUser,sum(z.signFullUser) as signFullUser from (select a.name ,c.name as depName,ifnull(d.count,0) as signUser,ifnull(e.count,0) as fullUser,
  1904. ifnull(f.count,0) as dayFullUser,ifnull(g.count,0) as dayNewUser,ifnull(h.count,0) as countUser,
  1905. ifnull(i.count,0) as signFullUser
  1906. from admin a inner join (select uid from user_role x
  1907. inner join(select id from `role` where role_name in ('营销员','营销经理','营销管理员')) y
  1908. on x.rid=y.id)b on a.id =b.uid left join department c on a.department_id=c.id
  1909. left join (select x.aid,count(1)as count from (select aid,uid from user_lock_release
  1910. where type=1 and status=0 group by aid,uid)x group by aid)d on a.id=d.aid
  1911. left join (select aid,count(1) as count from user where integrity=1 and type=1 and status=0 and share_type=0 group by aid) e on a.id=e.aid
  1912. left join (select aid,count(1) as count
  1913. from user where integrity=1 and type=1 and status=0 and share_type=0 and to_days(update_time)=to_days(now()) group by aid) f on a.id=f.aid
  1914. left join (select aid,count(1) as count
  1915. from user where type=1 and status=0 and share_type=0 and to_days(create_time)=to_days(now()) group by aid) g on a.id=g.aid
  1916. left join (select aid,count(1) as count
  1917. from user where type=1 and status=0 and share_type=0 group by aid) h on a.id=h.aid
  1918. left join (select x.aid,count(1)as count from (select x1.aid,x1.uid from user_lock_release x1
  1919. left join user y on x1.uid=y.id where x1.type=1
  1920. and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
  1921. where a.status='正常'
  1922. <if test="depId!=null and depId!=''">
  1923. and a.department_id= #{depId,jdbcType=VARCHAR}
  1924. </if>
  1925. )z
  1926. </select>
  1927. <select id="UserReceiveCount" parameterType="string" resultType="integer">
  1928. select count(*) from `user`
  1929. where aid= #{aid,jdbcType=VARCHAR}
  1930. and source=2
  1931. and share_type=0
  1932. and to_days(transfer_time)=to_days(now())
  1933. </select>
  1934. </mapper>