UserMapperExt.xml 72 KB

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