UserMapperExt.xml 74 KB

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