UserMapperExt.xml 73 KB

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