UserMapperExt.xml 83 KB

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