UserMapperExt.xml 93 KB

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