UserMapperExt.xml 90 KB

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