UserMapperExt.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  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.type,
  8. a.status,
  9. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  10. a.business_audit as businessAudit,
  11. a.current_member_status as currentMemberStatus,
  12. a.identify_name as name,
  13. a.lvl,a.is_member as isMember,
  14. a.society_tag as societyTag,
  15. a.share_type as shareType,
  16. b.contacts,
  17. b.contact_mobile as contactMobile,
  18. b.international,
  19. b.expert,
  20. b.celebrity,
  21. b.audit_status as auditStatus,
  22. b.consultant,
  23. dg1.name as province,
  24. dg2.name as city,
  25. dg3.name as area,
  26. c.name as industry,
  27. d.name as adminName
  28. from user a inner join user_identity b on a.id = b.uid
  29. left join district_glossory dg1 on b.province = dg1.id
  30. left join district_glossory dg2 on b.city = dg2.id
  31. left join district_glossory dg3 on b.area = dg3.id
  32. left join industry_category c on b.industry = c.id
  33. left join admin d on a.aid = d.id
  34. where a.type = 0 and a.status != 1
  35. <if test="aid != null and aid !=''">
  36. and a.aid = #{aid,jdbcType=VARCHAR}
  37. </if>
  38. <if test="name != null and name != ''">
  39. and a.identify_name like concat('%',#{name},'%')
  40. </if>
  41. <if test="shareType != null">
  42. and a.share_type = #{shareType,jdbcType=VARCHAR}
  43. </if>
  44. <if test="status != null">
  45. and a.status = #{status,jdbcType=INTEGER}
  46. </if>
  47. <if test="businessAudit != null">
  48. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  49. </if>
  50. <if test="isMember != null">
  51. and a.is_member = #{isMember,jdbcType=INTEGER}
  52. </if>
  53. <if test="lvl != null">
  54. and a.lvl = #{lvl,jdbcType=INTEGER}
  55. </if>
  56. <if test="currentMemberStatus != null">
  57. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  58. </if>
  59. <if test="societyTag != null and societyTag != ''">
  60. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  61. </if>
  62. <if test="startDate != null and startDate != ''">
  63. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  64. </if>
  65. <if test="endDate != null and endDate != ''">
  66. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  67. </if>
  68. <if test="province != null">
  69. and b.province = #{province,jdbcType=INTEGER}
  70. </if>
  71. <if test="city != null">
  72. and b.city = #{city,jdbcType=INTEGER}
  73. </if>
  74. <if test="area != null">
  75. and b.area = #{area,jdbcType=INTEGER}
  76. </if>
  77. <if test="industry != null">
  78. and b.industry = #{industry,jdbcType=INTEGER}
  79. </if>
  80. <if test="expert != null">
  81. and b.expert = #{expert,jdbcType=INTEGER}
  82. </if>
  83. <if test="celebrity != null">
  84. and b.celebrity = #{celebrity,jdbcType=INTEGER}
  85. </if>
  86. <if test="international != null">
  87. and b.international = #{international,jdbcType=INTEGER}
  88. </if>
  89. <if test="auditStatus != null">
  90. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  91. </if>
  92. order by a.create_time desc
  93. <if test="page_sql != null">
  94. ${page_sql}
  95. </if>
  96. </select>
  97. <select id="selectPersonalCustomerCount" resultType="java.lang.Integer">
  98. select count(0)
  99. from user a inner join user_identity b on a.id = b.uid
  100. where a.type = 0 and a.status != 1
  101. <if test="aid != null and aid !=''">
  102. and a.aid = #{aid,jdbcType=VARCHAR}
  103. </if>
  104. <if test="name != null and name != ''">
  105. and a.identify_name like concat('%',#{name},'%')
  106. </if>
  107. <if test="shareType != null">
  108. and a.share_type = #{shareType,jdbcType=VARCHAR}
  109. </if>
  110. <if test="status != null">
  111. and a.status = #{status,jdbcType=INTEGER}
  112. </if>
  113. <if test="businessAudit != null">
  114. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  115. </if>
  116. <if test="isMember != null">
  117. and a.is_member = #{isMember,jdbcType=INTEGER}
  118. </if>
  119. <if test="lvl != null">
  120. and a.lvl = #{lvl,jdbcType=INTEGER}
  121. </if>
  122. <if test="currentMemberStatus != null">
  123. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  124. </if>
  125. <if test="societyTag != null and societyTag != ''">
  126. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  127. </if>
  128. <if test="startDate != null and startDate != ''">
  129. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  130. </if>
  131. <if test="endDate != null and endDate != ''">
  132. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  133. </if>
  134. <if test="province != null">
  135. and b.province = #{province,jdbcType=INTEGER}
  136. </if>
  137. <if test="city != null">
  138. and b.city = #{city,jdbcType=INTEGER}
  139. </if>
  140. <if test="area != null">
  141. and b.area = #{area,jdbcType=INTEGER}
  142. </if>
  143. <if test="industry != null">
  144. and b.industry = #{industry,jdbcType=INTEGER}
  145. </if>
  146. <if test="expert != null">
  147. and b.expert = #{expert,jdbcType=INTEGER}
  148. </if>
  149. <if test="celebrity != null">
  150. and b.celebrity = #{celebrity,jdbcType=INTEGER}
  151. </if>
  152. <if test="international != null">
  153. and b.international = #{international,jdbcType=INTEGER}
  154. </if>
  155. <if test="auditStatus != null">
  156. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  157. </if>
  158. </select>
  159. <select id="selectOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  160. select
  161. a.id as uid,
  162. a.type,
  163. a.status,
  164. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  165. a.business_audit as businessAudit,
  166. a.current_member_status as currentMemberStatus,
  167. a.identify_name as name,
  168. a.lvl,
  169. a.is_member as isMember,
  170. a.society_tag as societyTag,
  171. share_type as shareType,
  172. b.contacts,
  173. b.contact_mobile as contactMobile,
  174. b.international,
  175. b.listed,
  176. b.high_tech_zone as highTechZone,
  177. b.audit_status as auditStatus,
  178. dg1.name as province,
  179. dg2.name as city,
  180. dg3.name as area,
  181. c.name as industry,
  182. d.name as adminName
  183. from user a inner join organization_identity b on a.id = b.uid
  184. left join district_glossory dg1 on b.location_province = dg1.id
  185. left join district_glossory dg2 on b.location_city = dg2.id
  186. left join district_glossory dg3 on b.location_area = dg3.id
  187. left join industry_category c on b.industry = c.id
  188. left join admin d on a.aid = d.id
  189. where a.type = 1 and a.status != 1
  190. <if test="aid != null and aid !=''">
  191. and a.aid = #{aid,jdbcType=VARCHAR}
  192. </if>
  193. <if test="name != null and name != ''">
  194. and a.identify_name like concat('%',#{name},'%')
  195. </if>
  196. <if test="shareType != null">
  197. and a.share_type = #{shareType,jdbcType=VARCHAR}
  198. </if>
  199. <if test="status != null">
  200. and a.status = #{status,jdbcType=INTEGER}
  201. </if>
  202. <if test="businessAudit != null">
  203. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  204. </if>
  205. <if test="isMember != null">
  206. and a.is_member = #{isMember,jdbcType=INTEGER}
  207. </if>
  208. <if test="currentMemberStatus != null">
  209. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  210. </if>
  211. <if test="lvl != null">
  212. and a.lvl = #{lvl,jdbcType=INTEGER}
  213. </if>
  214. <if test="societyTag != null and societyTag != ''">
  215. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  216. </if>
  217. <if test="startDate != null and startDate != ''">
  218. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  219. </if>
  220. <if test="endDate != null and endDate != ''">
  221. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  222. </if>
  223. <if test="province != null">
  224. and b.location_province = #{province,jdbcType=INTEGER}
  225. </if>
  226. <if test="city != null">
  227. and b.location_city = #{city,jdbcType=INTEGER}
  228. </if>
  229. <if test="area != null">
  230. and b.location_area = #{area,jdbcType=INTEGER}
  231. </if>
  232. <if test="industry != null">
  233. and b.industry = #{industry,jdbcType=INTEGER}
  234. </if>
  235. <if test="listed != null">
  236. and b.listed = #{listed,jdbcType=INTEGER}
  237. </if>
  238. <if test="highTechZone != null">
  239. and b.high_tech_zone = #{highTechZone,jdbcType=INTEGER}
  240. </if>
  241. <if test="international != null">
  242. and b.international = #{international,jdbcType=INTEGER}
  243. </if>
  244. <if test="auditStatus != null">
  245. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  246. </if>
  247. order by a.create_time desc
  248. <if test="page_sql != null">
  249. ${page_sql}
  250. </if>
  251. </select>
  252. <select id="selectOrganizationCustomerCount" resultType="java.lang.Integer">
  253. select
  254. count(0)
  255. from user a inner join organization_identity b on a.id = b.uid
  256. where a.type = 1 and a.status != 1
  257. <if test="aid != null and aid !=''">
  258. and a.aid = #{aid,jdbcType=VARCHAR}
  259. </if>
  260. <if test="name != null and name != ''">
  261. and a.identify_name like concat('%',#{name},'%')
  262. </if>
  263. <if test="shareType != null">
  264. and a.share_type = #{shareType,jdbcType=VARCHAR}
  265. </if>
  266. <if test="status != null">
  267. and a.status = #{status,jdbcType=INTEGER}
  268. </if>
  269. <if test="businessAudit != null">
  270. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  271. </if>
  272. <if test="currentMemberStatus != null">
  273. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  274. </if>
  275. <if test="isMember != null">
  276. and a.is_member = #{isMember,jdbcType=INTEGER}
  277. </if>
  278. <if test="societyTag != null and societyTag != ''">
  279. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  280. </if>
  281. <if test="startDate != null and startDate != ''">
  282. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  283. </if>
  284. <if test="endDate != null and endDate != ''">
  285. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  286. </if>
  287. <if test="province != null">
  288. and b.location_province = #{province,jdbcType=INTEGER}
  289. </if>
  290. <if test="city != null">
  291. and b.location_city = #{city,jdbcType=INTEGER}
  292. </if>
  293. <if test="area != null">
  294. and b.location_area = #{area,jdbcType=INTEGER}
  295. </if>
  296. <if test="industry != null">
  297. and b.industry = #{industry,jdbcType=INTEGER}
  298. </if>
  299. <if test="listed != null">
  300. and b.listed = #{listed,jdbcType=INTEGER}
  301. </if>
  302. <if test="highTechZone != null">
  303. and b.high_tech_zone = #{highTechZone,jdbcType=INTEGER}
  304. </if>
  305. <if test="international != null">
  306. and b.international = #{international,jdbcType=INTEGER}
  307. </if>
  308. <if test="auditStatus != null">
  309. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  310. </if>
  311. </select>
  312. <select id="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  313. select id,identify_name as name from user where identify_name like
  314. concat('%',#{identifyName},'%') and status <![CDATA[!= ]]> 1
  315. </select>
  316. <select id="judgeCustomerByName" resultType="java.lang.Integer">
  317. select count(0) from user where identify_name = #{identifyName,jdbcType=VARCHAR}
  318. and status <![CDATA[!= ]]> 1
  319. </select>
  320. <select id="findOrganizationCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOrganizationDetailBo">
  321. select
  322. a.id as uid,
  323. a.society_tag as societyTag,
  324. a.company_logo_url as companyLogoUrl,
  325. a.introduction,
  326. a.identify_name as identifyName,
  327. a.business_audit as businessAudit,
  328. b.industry,
  329. b.location_province as locationProvince,
  330. b.location_city as locationCity,
  331. b.location_area as locationArea,
  332. b.postal_address as postalAddress,
  333. b.contacts_fixed_tel as contactsFixedTel,
  334. b.contacts_fax as contactsFax,
  335. b.registered_capital registeredCapital,
  336. b.enterprise_scale as enterpriseScale,
  337. b.legal_person as legalPerson,
  338. b.legal_person_id_card as legalPersonIdCard,
  339. b.legal_person_tel as legalPersonTel,
  340. b.legal_person_email as legalPersonEmail,
  341. b.high_tech_zone highTechZone,
  342. b.listed,
  343. b.international,
  344. b.org_code as orgCode,
  345. b.org_code_url as orgCodeUrl,
  346. b.business_scope as businessScope,
  347. b.id,
  348. b.contacts,
  349. b.contact_mobile as contactMobile,
  350. b.investment,
  351. b.audit_status as auditStatus
  352. from
  353. user a inner join organization_identity b on a.id = b.uid
  354. where
  355. a.id = #{uid,jdbcType=VARCHAR}
  356. </select>
  357. <select id="findPersonalCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerPersonalDetailBo">
  358. select
  359. a.id as uid,
  360. a.identify_name as identifyName,
  361. a.society_tag as societyTag,
  362. a.head_portrait_url as headPortraitUrl,
  363. a.introduction,
  364. a.business_audit as businessAudit,
  365. b.id,
  366. b.industry,
  367. b.sex,
  368. b.date_of_birth_year as dateOfBirthYear,
  369. b.date_of_birth_month as dateOfBirthMonth,
  370. b.id_number as idNumber,
  371. b.province,
  372. b.city,
  373. b.area,
  374. b.positive_id_url as positiveIdUrl,
  375. b.opposite_id_url as oppositeIdUrl,
  376. b.postal_address as postalAddress,
  377. b.contact_mobile as contactMobile,
  378. b.fixed_tel as fixedTel,
  379. b.email,
  380. b.expert,
  381. b.celebrity,
  382. b.international,
  383. b.contacts,
  384. b.contact_mobile as contactMobile,
  385. b.qq,
  386. b.professional_title as professionalTitle,
  387. b.work_unit as workUnit,
  388. b.education,
  389. b.major_category as majorCategory,
  390. b.qualification,
  391. b.investment,
  392. b.audit_status as auditStatus,
  393. b.graduate_school as graduateSchool,
  394. b.consultant,
  395. b.consultation_price as consultationPrice
  396. from
  397. user a inner join user_identity b on
  398. a.id = b.uid
  399. where
  400. a.id = #{uid,jdbcType=VARCHAR}
  401. </select>
  402. <select id="selectFollowHistoryList" resultType="com.goafanti.customer.bo.FollowListBo">
  403. select
  404. a.id as followId,
  405. a.create_time as followTime,
  406. a.contact_type as contactType,
  407. a.result,
  408. b.identify_name as identifyName,
  409. c.name as contacts,
  410. c.mobile as contactMobile,
  411. d.name as adminName
  412. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  413. ,e.id as ufbId,e.follow_situation as followSituation,e.customer_status as customerStatus
  414. </if>
  415. from user_follow a
  416. left join user b on a.uid = b.id
  417. left join organization_contact_book c on a.ocb_id = c.id
  418. left join admin d on a.aid = d.id
  419. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  420. inner join user_follow_business e on a.id = e.follow_id
  421. </if>
  422. where a.effective = 0
  423. <if test="uid != null and uid != ''">
  424. and a.uid = #{uid,jdbcType=VARCHAR}
  425. </if>
  426. <if test="aid != null and aid != ''">
  427. and a.aid = #{aid,jdbcType=VARCHAR}
  428. </if>
  429. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  430. and e.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  431. </if>
  432. <if test="page_sql != null">
  433. ${page_sql}
  434. </if>
  435. </select>
  436. <select id="selectFollowHistoryCount" resultType="java.lang.Integer">
  437. select
  438. count(0)
  439. from user_follow a
  440. left join user b on a.uid = b.id
  441. left join organization_contact_book c on a.ocb_id = c.id
  442. left join admin d on a.aid = d.id
  443. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  444. inner join user_follow_business e on a.id = e.follow_id
  445. </if>
  446. where a.effective = 0
  447. <if test="uid != null and uid != ''">
  448. and a.uid = #{uid,jdbcType=VARCHAR}
  449. </if>
  450. <if test="aid != null and aid != ''">
  451. and a.aid = #{aid,jdbcType=VARCHAR}
  452. </if>
  453. <if test="businessGlossoryId != null and businessGlossoryId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  454. and e.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  455. </if>
  456. </select>
  457. <select id="findUserAccountDetail" parameterType="java.lang.String" resultType="com.goafanti.common.model.User">
  458. select
  459. id,
  460. mobile,
  461. nickname,
  462. create_time as createTime,
  463. type,
  464. source,
  465. email,
  466. is_member as isMember,
  467. lvl,
  468. current_member_status currentMemberStatus,
  469. business_audit as businessAudit,
  470. identify_name as identifyName,
  471. status
  472. from
  473. user
  474. where id = #{uid,jdbcType=VARCHAR}
  475. </select>
  476. <select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  477. select id,name,mobile,email,qq,wechat,depatrment,position from organization_contact_book
  478. where uid = #{uid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR}
  479. </select>
  480. <select id="findAllContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  481. select id,name,mobile from organization_contact_book
  482. where uid = #{uid,jdbcType=VARCHAR}
  483. </select>
  484. <select id="findFollowById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.FollowBusinessBo">
  485. select
  486. a.id as followId,
  487. a.uid,
  488. a.ocb_id as ocbId,
  489. a.contact_type as contactType,
  490. a.result,
  491. a.create_time as followTime,
  492. b.identify_name as identifyName,
  493. c.name as contacts,
  494. c.mobile as contactType,
  495. d.name as adminName
  496. from
  497. user_follow a
  498. left join user b on a.uid = b.id
  499. left join organization_contact_book c on a.ocb_id = c.id
  500. left join admin d on a.aid = d.id
  501. where a.id = #{followId,jdbcType=VARCHAR}
  502. </select>
  503. <select id="customerStatisticsList" resultType="com.goafanti.customer.bo.StatisticBo">
  504. select a.*,b.name as adminName,c.name as departmentName from (
  505. select
  506. aid,
  507. sum(case when customer_status = 0 then 1 else 0 end) as newNo, <!-- 新客户 -->
  508. sum(case when customer_status = 1 then 1 else 0 end) as intentionNo, <!-- 意向客户 -->
  509. sum(case when customer_status = 2 then 1 else 0 end) as pointNo, <!-- 重点客户 -->
  510. sum(case when customer_status = 3 then 1 else 0 end) as interviewNo, <!-- 面谈客户 -->
  511. sum(case when customer_status = 4 then 1 else 0 end) as signNo, <!-- 签单客户 -->
  512. sum(case when customer_status = 5 then 1 else 0 end) as refuseNo, <!-- 拒绝客户 -->
  513. sum(case when customer_status = 6 then 1 else 0 end) as stopNo <!-- 停止跟进 -->
  514. from user_business where 1=1
  515. <if test="sDate != null">
  516. and create_time &gt; #{sDate,jdbcType=DATE}
  517. </if>
  518. <if test="eDate != null">
  519. and create_time &lt; #{eDate,jdbcType=DATE}
  520. </if>
  521. <if test="businessGlossoryId != null">
  522. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  523. </if>
  524. group by aid
  525. )a
  526. left join admin b on a.aid = b.id
  527. left join department_management c on b.department_id = c.id
  528. <if test="depNo != null">
  529. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  530. </if>
  531. <if test="page_sql != null">
  532. ${page_sql}
  533. </if>
  534. </select>
  535. <select id="customerStatisticsCount" resultType="java.lang.Integer">
  536. select count(0) from (
  537. select
  538. aid
  539. from user_business where 1=1
  540. <if test="sDate != null">
  541. and create_time &gt; #{sDate,jdbcType=DATE}
  542. </if>
  543. <if test="eDate != null">
  544. and create_time &lt; #{eDate,jdbcType=DATE}
  545. </if>
  546. <if test="businessGlossoryId != null">
  547. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  548. </if>
  549. group by aid
  550. )a
  551. left join admin b on a.aid = b.id
  552. left join department_management c on b.department_id = c.id
  553. <if test="depNo !=null">
  554. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  555. </if>
  556. </select>
  557. <select id="businessStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  558. select a.*,b.name as adminName,c.name as departmentName from (
  559. select
  560. aid,
  561. sum(case when follow_situation = 0 then 1 else 0 end) as sendMaterialNo, <!-- 已发项目介绍资料 -->
  562. sum(case when follow_situation = 1 then 1 else 0 end) as interviewNo, <!-- 已约面谈 -->
  563. sum(case when follow_situation = 2 then 1 else 0 end) as sendProspectusNo, <!-- 已发合同计划书 -->
  564. sum(case when follow_situation = 3 then 1 else 0 end) as quoteNo, <!-- 已报价 -->
  565. sum(case when follow_situation = 4 then 1 else 0 end) as sendContractNo, <!-- 已发合同 -->
  566. sum(case when follow_situation = 5 then 1 else 0 end) as signContractNo, <!-- 已签合同 -->
  567. sum(case when follow_situation = 6 then 1 else 0 end) as onVisaNo, <!-- 面谈中 -->
  568. sum(case when follow_situation = 7 then 1 else 0 end) as visaNo <!-- 已面签 -->
  569. from user_business where 1=1
  570. <if test="sDate != null">
  571. and create_time &gt; #{sDate,jdbcType=DATE}
  572. </if>
  573. <if test="eDate != null">
  574. and create_time &lt; #{eDate,jdbcType=DATE}
  575. </if>
  576. <if test="businessGlossoryId != null">
  577. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  578. </if>
  579. group by aid
  580. )a
  581. left join admin b on a.aid = b.id
  582. left join department_management c on b.department_id = c.id
  583. <if test="depNo !=null">
  584. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  585. </if>
  586. <if test="page_sql != null">
  587. ${page_sql}
  588. </if>
  589. </select>
  590. <select id="businessStatisticCount" resultType="java.lang.Integer">
  591. select count(0) from (
  592. select
  593. aid
  594. from user_business where 1=1
  595. <if test="sDate != null">
  596. and create_time &gt; #{sDate,jdbcType=DATE}
  597. </if>
  598. <if test="eDate != null">
  599. and create_time &lt; #{eDate,jdbcType=DATE}
  600. </if>
  601. <if test="businessGlossoryId != null">
  602. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  603. </if>
  604. group by aid
  605. )a
  606. left join admin b on a.aid = b.id
  607. left join department_management c on b.department_id = c.id
  608. <if test="depNo !=null">
  609. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  610. </if>
  611. </select>
  612. <select id="followStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  613. select x.*,b.name as adminName,c.name as departmentName,y.* from (
  614. select
  615. count(0) as followNo,
  616. aid,
  617. sum(case when contact_type = 0 then 1 else 0 end) as visitNo, <!-- 外出 -->
  618. sum(case when contact_type = 1 then 1 else 0 end) as telNo, <!-- 电话 -->
  619. sum(case when contact_type = 2 then 1 else 0 end) as qqNo, <!-- QQ -->
  620. sum(case when contact_type = 3 then 1 else 0 end) as wxNo, <!-- 微信 -->
  621. sum(case when contact_type = 4 then 1 else 0 end) as emailNo, <!-- 邮件 -->
  622. sum(case when contact_type = 5 then 1 else 0 end) as letterNo <!-- 书信 -->
  623. from user_follow where 1=1
  624. <if test="sDate != null">
  625. and create_time &gt; #{sDate,jdbcType=DATE}
  626. </if>
  627. <if test="eDate != null">
  628. and create_time &lt; #{eDate,jdbcType=DATE}
  629. </if>
  630. group by aid
  631. )x
  632. left join admin b on x.aid = b.id
  633. left join department_management c on b.department_id = c.id
  634. left join
  635. (
  636. select
  637. count( 0 ) as customerNo,
  638. aid
  639. from
  640. (
  641. select
  642. aid,
  643. uid
  644. from
  645. user_follow
  646. group by
  647. aid,
  648. uid
  649. ) a
  650. group by
  651. aid
  652. )y on x.aid = y.aid
  653. <if test="depNo !=null">
  654. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  655. </if>
  656. </select>
  657. <select id="followStatisticCount" resultType="java.lang.Integer">
  658. select count(0) from (
  659. select
  660. aid
  661. from user_follow where 1=1
  662. <if test="sDate != null">
  663. and create_time &gt; #{sDate,jdbcType=DATE}
  664. </if>
  665. <if test="sDate != null">
  666. and create_time &lt; #{eDate,jdbcType=DATE}
  667. </if>
  668. group by aid
  669. )x
  670. left join admin b on x.aid = b.id
  671. left join department_management c on b.department_id = c.id
  672. <if test="depNo !=null">
  673. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  674. </if>
  675. </select>
  676. <select id="findBusinessByFollowId" parameterType="java.lang.String" resultType="com.goafanti.common.model.UserBusiness">
  677. select
  678. a.id,
  679. a.follow_situation as followSituation,
  680. a.customer_status as customerStatus,
  681. a.remarks,
  682. a.business_glossory_id as businessGlossoryId
  683. from
  684. user_follow_business a
  685. where a.follow_id = #{followId,jdbcType=VARCHAR}
  686. </select>
  687. <select id="selectBusinessList" resultType="com.goafanti.customer.bo.BusinessListBo">
  688. select
  689. c.name as businessName,
  690. b.identify_name as identifyName,
  691. a.id as businessId,
  692. a.create_time as createTime,
  693. a.update_time as updateTime,
  694. a.follow_situation as followSituation,
  695. a.customer_status as customerStatus,
  696. d.name as adminName
  697. from
  698. user_business a inner join user b on
  699. a.uid = b.id left join business_glossory c on
  700. a.business_glossory_id = c.id left join admin d on
  701. a.aid = d.id
  702. where 1 = 1
  703. <if test="aid != null and aid != ''">
  704. and a.aid = #{aid,jdbcType=VARCHAR}
  705. </if>
  706. <if test="uid != null and uid !=''">
  707. and a.uid = #{uid,jdbcType=VARCHAR}
  708. </if>
  709. <if test="businessGlossoryId !=null and businessGlossoryId != ''">
  710. and a.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  711. </if>
  712. <if test="identifyName != null and identifyName != ''">
  713. and b.identify_name like concat('%', #{identifyName},'%')
  714. </if>
  715. <if test="followSituation != null">
  716. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  717. </if>
  718. <if test="customerStatus != null">
  719. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  720. </if>
  721. <if test="adminName != null and adminName != ''">
  722. and d.name = #{adminName,jdbcType=VARCHAR}
  723. </if>
  724. <if test="startDate != null and startDate != ''">
  725. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  726. </if>
  727. <if test="endDate != null and endDate != ''">
  728. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  729. </if>
  730. <if test="page_sql != null">
  731. ${page_sql}
  732. </if>
  733. </select>
  734. <select id="selectBusinessCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
  735. select
  736. count(0)
  737. from
  738. user_business a inner join user b on
  739. a.uid = b.id left join business_glossory c on
  740. a.business_glossory_id = c.id left join admin d on
  741. a.aid = d.id
  742. where 1 = 1
  743. <if test="aid != null and aid != ''">
  744. and a.aid = #{aid,jdbcType=VARCHAR}
  745. </if>
  746. <if test="uid != null and uid !=''">
  747. and a.uid = #{uid,jdbcType=VARCHAR}
  748. </if>
  749. <if test="businessGlossoryId !=null and businessGlossoryId != ''">
  750. and a.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  751. </if>
  752. <if test="identifyName != null and identifyName != ''">
  753. and b.identify_name like concat('%', #{identifyName},'%')
  754. </if>
  755. <if test="followSituation != null">
  756. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  757. </if>
  758. <if test="customerStatus != null">
  759. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  760. </if>
  761. <if test="adminName != null and adminName != ''">
  762. and d.name = #{adminName,jdbcType=VARCHAR}
  763. </if>
  764. <if test="startDate != null and startDate != ''">
  765. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  766. </if>
  767. <if test="endDate != null and endDate != ''">
  768. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  769. </if>
  770. </select>
  771. </mapper>