UserMapperExt.xml 82 KB

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