UserMapperExt.xml 79 KB

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