UserMapperExt.xml 93 KB

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