UserMapperExt.xml 82 KB

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