ClueMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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.management.platform.mapper.ClueMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.Clue">
  6. <id column="id" property="id" />
  7. <result column="company_id" property="companyId" />
  8. <result column="clue_name" property="clueName" />
  9. <result column="clue_source_id" property="clueSourceId" />
  10. <result column="phone" property="phone" />
  11. <result column="email" property="email" />
  12. <result column="customer_industry_id" property="customerIndustryId" />
  13. <result column="customer_level_id" property="customerLevelId" />
  14. <result column="address" property="address" />
  15. <result column="incharger_id" property="inchargerId" />
  16. <result column="remark" property="remark" />
  17. <result column="is_delete" property="isDelete" />
  18. <result column="plate1" property="plate1" />
  19. <result column="plate2" property="plate2" />
  20. <result column="plate3" property="plate3" />
  21. <result column="plate4" property="plate4" />
  22. <result column="plate5" property="plate5" />
  23. <result column="company_name" property="companyName" />
  24. <result column="create_time" property="createTime" />
  25. <result column="create_id" property="createId" />
  26. </resultMap>
  27. <!-- 通用查询结果列 -->
  28. <sql id="Base_Column_List">
  29. id, company_id, clue_name, clue_source_id, phone , email, customer_industry_id, customer_level_id, address, incharger_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5,create_time,createId
  30. </sql>
  31. <select id="list" resultType="com.management.platform.entity.Clue">
  32. select c.id,
  33. c.company_id,
  34. c.clue_name,
  35. c.clue_source_id,
  36. c.phone,
  37. c.email,
  38. c.customer_industry_id,
  39. c.customer_level_id,
  40. c.address,
  41. c.incharger_id,
  42. c.remark,
  43. c.is_delete,
  44. c.plate1,
  45. c.plate2,
  46. c.plate3,
  47. c.plate4,
  48. c.plate5,
  49. c.create_time,
  50. c.create_id,
  51. (select company_name from company where c.company_id = id) companyName,
  52. (select name from `user` where id = c.incharger_id) inchargerName,
  53. (select name from `user` where id = c.create_id) createName,
  54. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  55. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  56. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  57. from clue c
  58. left join sys_dict sd on c.customer_level_id = sd.id
  59. where
  60. c.company_id = #{companyId} and is_delete = #{isDelete} and c.is_bo = 0
  61. <if test="inchargerId != null and inchargerId != '' ">
  62. and c.incharger_id =#{inchargerId}
  63. </if>
  64. <if test="startTime != null and endTime != null ">
  65. and c.create_time BETWEEN #{startTime} and #{endTime}
  66. </if>
  67. <if test="clueName != null and clueName != '' ">
  68. and c.clue_name LIKE CONCAT('%', #{clueName}, '%')
  69. </if>
  70. <if test="phone != null and phone != '' ">
  71. and c.phone LIKE CONCAT('%', #{phone}, '%')
  72. </if>
  73. <if test="customerLevelId != null and customerLevelId != '' ">
  74. and c.customer_level_id = #{customerLevelId}
  75. </if>
  76. <if test="email != null and email != '' ">
  77. and c.email LIKE CONCAT('%', #{email}, '%')
  78. </if>
  79. <if test="clueSourceId != null">
  80. and c.clue_source_id = #{clueSourceId}
  81. </if>
  82. <if test="customerIndustryId != null">
  83. and c.customer_industry_id = #{customerIndustryId}
  84. </if>
  85. ORDER BY
  86. <choose>
  87. <when test="isDesc == null ">
  88. c.id DESC
  89. </when>
  90. <when test="isDesc == 0">
  91. sd.seq ASC, c.id DESC
  92. </when>
  93. <when test="isDesc == 1">
  94. sd.seq DESC, c.id DESC
  95. </when>
  96. <otherwise>
  97. c.id DESC
  98. </otherwise>
  99. </choose>
  100. limit #{pageIndex},#{pageFrom}
  101. </select>
  102. <select id="list1" resultType="com.management.platform.entity.Clue">
  103. select c.id,
  104. c.company_id,
  105. (select company_name from company where company_id = c.id) companyName,
  106. c.clue_name,
  107. c.clue_source_id,
  108. c.phone,
  109. c.email,
  110. c.customer_industry_id,
  111. c.customer_level_id,
  112. c.address,
  113. c.incharger_id,
  114. c.remark,
  115. c.is_delete,
  116. c.plate1,
  117. c.plate2,
  118. c.plate3,
  119. c.plate4,
  120. c.plate5,
  121. c.create_time,
  122. c.create_id,
  123. (select name from `user` where id = c.incharger_id) inchargerName,
  124. (select name from `user` where id = c.create_id) createName,
  125. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  126. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  127. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  128. from clue c
  129. left join sys_dict sd on c.customer_level_id = sd.id
  130. where
  131. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  132. and (c.incharger_id in
  133. (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
  134. or c.incharger_id is null)
  135. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  136. and c.incharger_id =#{clue.inchargerId}
  137. </if>
  138. <if test="clue.startTime != null and clue.endTime != null ">
  139. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  140. </if>
  141. <if test="clue.clueName != null and clue.clueName != '' ">
  142. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  143. </if>
  144. <if test="clue.clueSourceId != null">
  145. and c.clue_source_id = #{clue.clueSourceId}
  146. </if>
  147. <if test="clue.phone != null and clue.phone != '' ">
  148. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  149. </if>
  150. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  151. and c.customer_level_id = #{clue.customerLevelId}
  152. </if>
  153. <if test="clue.email != null and clue.email != '' ">
  154. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  155. </if>
  156. <if test="clue.customerIndustryId != null">
  157. and c.customer_industry_id = #{clue.customerIndustryId}
  158. </if>
  159. ORDER BY
  160. <choose>
  161. <when test="isDesc == null">
  162. c.id DESC
  163. </when>
  164. <when test="isDesc == 0">
  165. sd.seq ASC, c.id DESC
  166. </when>
  167. <when test="isDesc == 1">
  168. sd.seq DESC, c.id DESC
  169. </when>
  170. <otherwise>
  171. c.id DESC
  172. </otherwise>
  173. </choose>
  174. limit #{clue.pageIndex},#{clue.pageFrom}
  175. </select>
  176. <select id="list2" resultType="com.management.platform.entity.Clue">
  177. select c.id,
  178. c.company_id,
  179. (select company_name from company where c.company_id = c.id) companyName,
  180. c.clue_name,
  181. c.clue_source_id,
  182. c.phone,
  183. c.email,
  184. c.customer_industry_id,
  185. c.customer_level_id,
  186. c.address,
  187. c.incharger_id,
  188. c.remark,
  189. c.is_delete,
  190. c.plate1,
  191. c.plate2,
  192. c.plate3,
  193. c.plate4,
  194. c.plate5,
  195. c.create_time,
  196. c.create_id,
  197. (select name from `user` where id = c.incharger_id) inchargerName,
  198. (select name from `user` where id = c.create_id) createName,
  199. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  200. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  201. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  202. from clue c
  203. left join sys_dict sd on c.customer_level_id = sd.id
  204. where
  205. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  206. and (c.incharger_id = #{userId} or c.incharger_id is null)
  207. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  208. and c.incharger_id =#{clue.inchargerId}
  209. </if>
  210. <if test="clue.startTime != null and clue.endTime != null ">
  211. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  212. </if>
  213. <if test="clue.clueName != null and clue.clueName != '' ">
  214. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  215. </if>
  216. <if test="clue.phone != null and clue.phone != '' ">
  217. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  218. </if>
  219. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  220. and c.customer_level_id = #{clue.customerLevelId}
  221. </if>
  222. <if test="clue.email != null and clue.email != '' ">
  223. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  224. </if>
  225. <if test="clue.clueSourceId != null">
  226. and c.clue_source_id = #{clue.clueSourceId}
  227. </if>
  228. <if test="clue.customerIndustryId != null">
  229. and c.customer_industry_id = #{clue.customerIndustryId}
  230. </if>
  231. ORDER BY
  232. <choose>
  233. <when test="clue.isDesc == null ">
  234. c.id DESC
  235. </when>
  236. <when test="clue.isDesc == 0">
  237. sd.seq ASC, c.id DESC
  238. </when>
  239. <when test="clue.isDesc == 1">
  240. sd.seq DESC, c.id DESC
  241. </when>
  242. <otherwise>
  243. c.id DESC
  244. </otherwise>
  245. </choose>
  246. limit #{clue.pageIndex},#{clue.pageFrom}
  247. </select>
  248. <select id="getTotal" resultType="java.lang.Integer">
  249. select count(*)
  250. from clue c
  251. where
  252. company_id = #{companyId} and is_delete = #{isDelete} and is_bo = 0
  253. <if test="inchargerId != null and inchargerId != '' ">
  254. and incharger_id = #{inchargerId}
  255. </if>
  256. <if test="startTime != null and endTime != null ">
  257. and create_time BETWEEN #{startTime} and #{endTime}
  258. </if>
  259. <if test="clueName != null and clueName != '' ">
  260. and clue_name LIKE CONCAT('%', #{clueName}, '%')
  261. </if>
  262. <if test="phone != null and phone != '' ">
  263. and phone LIKE CONCAT('%', #{phone}, '%')
  264. </if>
  265. <if test="email != null and email != '' ">
  266. and email LIKE CONCAT('%', #{email}, '%')
  267. </if>
  268. <if test="customerLevelId != null and customerLevelId != '' ">
  269. and customer_level_id = #{customerLevelId}
  270. </if>
  271. <if test="clueSourceId != null">
  272. and clue_source_id = #{clueSourceId}
  273. </if>
  274. <if test="customerIndustryId != null">
  275. and customer_industry_id = #{customerIndustryId}
  276. </if>
  277. </select>
  278. <select id="getTotal1" resultType="java.lang.Integer">
  279. select
  280. COUNT(c.id)
  281. from clue c
  282. where
  283. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  284. and c.incharger_id in
  285. (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
  286. and c.incharger_id is null
  287. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  288. and c.incharger_id =#{clue.inchargerId}
  289. </if>
  290. <if test="clue.startTime != null and clue.endTime != null ">
  291. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  292. </if>
  293. <if test="clue.clueName != null and clue.clueName != '' ">
  294. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  295. </if>
  296. <if test="clue.phone != null and clue.phone != '' ">
  297. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  298. </if>
  299. <if test="clue.email != null and clue.email != '' ">
  300. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  301. </if>
  302. <if test="clue.clueSourceId != null">
  303. and c.clue_source_id = #{clue.clueSourceId}
  304. </if>
  305. <if test="clue.customerIndustryId != null">
  306. and c.customer_industry_id = #{clue.customerIndustryId}
  307. </if>
  308. <if test="clue.customerLevelId != null">
  309. and c.customerLevelId = #{clue.customerLevelId}
  310. </if>
  311. </select>
  312. <select id="getTotal2" resultType="java.lang.Integer">
  313. select
  314. count(c.id)
  315. from clue c
  316. where
  317. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  318. and (c.incharger_id = #{userId} or c.incharger_id is null)
  319. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  320. and c.incharger_id =#{clue.inchargerId}
  321. </if>
  322. <if test="clue.startTime != null and clue.endTime != null ">
  323. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  324. </if>
  325. <if test="clue.clueName != null and clue.clueName != '' ">
  326. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  327. </if>
  328. <if test="clue.phone != null and clue.phone != '' ">
  329. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  330. </if>
  331. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  332. and c.customer_level_id = #{clue.customerLevelId}
  333. </if>
  334. <if test="clue.email != null and clue.email != '' ">
  335. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  336. </if>
  337. <if test="clue.clueSourceId != null">
  338. and c.clue_source_id = #{clue.clueSourceId}
  339. </if>
  340. <if test="clue.customerIndustryId != null">
  341. and c.customer_industry_id = #{clue.customerIndustryId}
  342. </if>
  343. </select>
  344. <select id="getDataSummary" resultType="java.util.Map">
  345. SELECT COUNT(*) newNum,SUM(bo.clue_id is not null) as changeNum
  346. FROM clue c
  347. left join business_opportunity bo on c.id=bo.clue_id
  348. WHERE c.company_id=#{companyId} and c.is_delete=0
  349. <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
  350. and DATE_FORMAT(c.create_time,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  351. </if>
  352. <if test="userId!=null and userId!=''">
  353. and c.incharger_id=#{userId}
  354. </if>
  355. <if test="list!=null and list.size()>0">
  356. and c.incharger_id in
  357. <foreach collection="list" separator="," open="(" close=")" item="item">
  358. #{item}
  359. </foreach>
  360. </if>
  361. </select>
  362. <select id="getAllList" resultType="com.management.platform.entity.Clue">
  363. select id,
  364. clue_name
  365. from clue
  366. where company_id =#{companyId}
  367. </select>
  368. <select id="getAlllist1" resultType="com.management.platform.entity.Clue">
  369. select id,
  370. clue_name
  371. from clue c
  372. left join sys_dict sd on c.customer_level_id = sd.id
  373. where
  374. c.company_id = #{companyId} and is_delete = #{isDelete}
  375. and (c.incharger_id in
  376. (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
  377. or c.incharger_id is null)
  378. </select>
  379. <select id="getAllList2" resultType="com.management.platform.entity.Clue">
  380. select c.id,
  381. c.clue_name
  382. from clue c
  383. left join sys_dict sd on c.customer_level_id = sd.id
  384. where
  385. c.company_id = #{companyId} and c.is_delete = #{isDelete}
  386. and (c.incharger_id = #{userId} or c.incharger_id is null)
  387. </select>
  388. <select id="listByPin" resultType="com.management.platform.entity.Clue">
  389. select c.id,
  390. c.company_id,
  391. c.clue_name,
  392. c.clue_source_id,
  393. c.phone,
  394. c.email,
  395. c.customer_industry_id,
  396. c.customer_level_id,
  397. c.address,
  398. c.incharger_id,
  399. c.remark,
  400. c.is_delete,
  401. c.plate1,
  402. c.plate2,
  403. c.plate3,
  404. c.plate4,
  405. c.plate5,
  406. c.create_time,
  407. c.create_id,
  408. (select company_name from company where c.company_id = id) companyName,
  409. (select name from `user` where id = c.incharger_id) inchargerName,
  410. (select name from `user` where id = c.create_id) createName,
  411. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  412. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  413. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  414. from clue c
  415. left join sys_dict sd on c.customer_level_id = sd.id
  416. where
  417. c.company_id = #{companyId} and is_delete = #{isDelete} and c.is_bo = 0
  418. <if test="inchargerId != null and inchargerId != '' ">
  419. and c.incharger_id =#{inchargerId}
  420. </if>
  421. <if test="startTime != null and endTime != null ">
  422. and c.create_time BETWEEN #{startTime} and #{endTime}
  423. </if>
  424. <if test="clueName != null and clueName != '' ">
  425. and c.clue_name LIKE CONCAT('%', #{clueName}, '%')
  426. </if>
  427. <if test="phone != null and phone != '' ">
  428. and c.phone LIKE CONCAT('%', #{phone}, '%')
  429. </if>
  430. <if test="customerLevelId != null and customerLevelId != '' ">
  431. and c.customer_level_id = #{customerLevelId}
  432. </if>
  433. <if test="email != null and email != '' ">
  434. and c.email LIKE CONCAT('%', #{email}, '%')
  435. </if>
  436. <if test="clueSourceId != null">
  437. and c.clue_source_id = #{clueSourceId}
  438. </if>
  439. <if test="customerIndustryId != null">
  440. and c.customer_industry_id = #{customerIndustryId}
  441. </if>
  442. order by c.need_pin desc,c.pin_time desc
  443. <choose>
  444. <when test="isDesc == null ">
  445. ,c.id DESC
  446. </when>
  447. <when test="isDesc == 0">
  448. ,sd.seq ASC, c.id DESC
  449. </when>
  450. <when test="isDesc == 1">
  451. ,sd.seq DESC, c.id DESC
  452. </when>
  453. <otherwise>
  454. ,c.id DESC
  455. </otherwise>
  456. </choose>
  457. limit #{pageIndex},#{pageFrom}
  458. </select>
  459. <select id="list1ByPin" resultType="com.management.platform.entity.Clue">
  460. select c.id,
  461. c.company_id,
  462. (select company_name from company where company_id = c.id) companyName,
  463. c.clue_name,
  464. c.clue_source_id,
  465. c.phone,
  466. c.email,
  467. c.customer_industry_id,
  468. c.customer_level_id,
  469. c.address,
  470. c.incharger_id,
  471. c.remark,
  472. c.is_delete,
  473. c.plate1,
  474. c.plate2,
  475. c.plate3,
  476. c.plate4,
  477. c.plate5,
  478. c.create_time,
  479. c.create_id,
  480. (select name from `user` where id = c.incharger_id) inchargerName,
  481. (select name from `user` where id = c.create_id) createName,
  482. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  483. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  484. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  485. from clue c
  486. left join sys_dict sd on c.customer_level_id = sd.id
  487. where
  488. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  489. and (c.incharger_id in
  490. (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
  491. or c.incharger_id is null)
  492. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  493. and c.incharger_id =#{clue.inchargerId}
  494. </if>
  495. <if test="clue.startTime != null and clue.endTime != null ">
  496. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  497. </if>
  498. <if test="clue.clueName != null and clue.clueName != '' ">
  499. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  500. </if>
  501. <if test="clue.clueSourceId != null">
  502. and c.clue_source_id = #{clue.clueSourceId}
  503. </if>
  504. <if test="clue.phone != null and clue.phone != '' ">
  505. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  506. </if>
  507. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  508. and c.customer_level_id = #{clue.customerLevelId}
  509. </if>
  510. <if test="clue.email != null and clue.email != '' ">
  511. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  512. </if>
  513. <if test="clue.customerIndustryId != null">
  514. and c.customer_industry_id = #{clue.customerIndustryId}
  515. </if>
  516. order by c.need_pin desc,c.pin_time desc
  517. <choose>
  518. <when test="isDesc == null">
  519. ,c.id DESC
  520. </when>
  521. <when test="isDesc == 0">
  522. ,sd.seq ASC, c.id DESC
  523. </when>
  524. <when test="isDesc == 1">
  525. ,sd.seq DESC, c.id DESC
  526. </when>
  527. <otherwise>
  528. ,c.id DESC
  529. </otherwise>
  530. </choose>
  531. limit #{clue.pageIndex},#{clue.pageFrom}
  532. </select>
  533. <select id="list2ByPin" resultType="com.management.platform.entity.Clue">
  534. select c.id,
  535. c.company_id,
  536. (select company_name from company where c.company_id = c.id) companyName,
  537. c.clue_name,
  538. c.clue_source_id,
  539. c.phone,
  540. c.email,
  541. c.customer_industry_id,
  542. c.customer_level_id,
  543. c.address,
  544. c.incharger_id,
  545. c.remark,
  546. c.is_delete,
  547. c.plate1,
  548. c.plate2,
  549. c.plate3,
  550. c.plate4,
  551. c.plate5,
  552. c.create_time,
  553. c.create_id,
  554. (select name from `user` where id = c.incharger_id) inchargerName,
  555. (select name from `user` where id = c.create_id) createName,
  556. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  557. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  558. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  559. from clue c
  560. left join sys_dict sd on c.customer_level_id = sd.id
  561. where
  562. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  563. and (c.incharger_id = #{userId} or c.incharger_id is null)
  564. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  565. and c.incharger_id =#{clue.inchargerId}
  566. </if>
  567. <if test="clue.startTime != null and clue.endTime != null ">
  568. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  569. </if>
  570. <if test="clue.clueName != null and clue.clueName != '' ">
  571. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  572. </if>
  573. <if test="clue.phone != null and clue.phone != '' ">
  574. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  575. </if>
  576. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  577. and c.customer_level_id = #{clue.customerLevelId}
  578. </if>
  579. <if test="clue.email != null and clue.email != '' ">
  580. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  581. </if>
  582. <if test="clue.clueSourceId != null">
  583. and c.clue_source_id = #{clue.clueSourceId}
  584. </if>
  585. <if test="clue.customerIndustryId != null">
  586. and c.customer_industry_id = #{clue.customerIndustryId}
  587. </if>
  588. order by c.need_pin desc,c.pin_time desc
  589. <choose>
  590. <when test="clue.isDesc == null ">
  591. ,c.id DESC
  592. </when>
  593. <when test="clue.isDesc == 0">
  594. ,sd.seq ASC, c.id DESC
  595. </when>
  596. <when test="clue.isDesc == 1">
  597. ,sd.seq DESC, c.id DESC
  598. </when>
  599. <otherwise>
  600. ,c.id DESC
  601. </otherwise>
  602. </choose>
  603. limit #{clue.pageIndex},#{clue.pageFrom}
  604. </select>
  605. </mapper>