UserMapperExt.xml 70 KB

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