UserMapperExt.xml 87 KB

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