UserMapperExt.xml 71 KB

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