UserMapperExt.xml 74 KB

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