UserMapperExt.xml 75 KB

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