UserMapperExt.xml 82 KB

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