UserMapperExt.xml 82 KB

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