UserMapperExt.xml 74 KB

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