UserMapperExt.xml 82 KB

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