TaPersonMapper.xml 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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.huiju.estateagents.mapper.TaPersonMapper">
  4. <select id="selectCardList" resultType="java.util.HashMap">
  5. SELECT
  6. t.person_id AS id,
  7. t.name,
  8. t.company,
  9. t.department,
  10. t.post,
  11. t.user_id as userId,
  12. t.tel AS phone,
  13. t.avatarurl AS avatar,
  14. t.photo,
  15. u.description as description,
  16. (t.person_id = #{consultant} or t.user_id = #{consultant}) as mine
  17. FROM
  18. ta_person t left join ta_user u on t.user_id = u.user_id
  19. LEFT JOIN ta_person_building p ON u.user_id = p.user_id
  20. WHERE
  21. t.person_type = #{personType}
  22. AND t.status = #{status}
  23. and u.status != 9
  24. and t.org_id = #{orgId}
  25. <if test="buildingId != null and buildingId != ''">
  26. and p.building_id = #{buildingId}
  27. </if>
  28. ORDER BY
  29. u.weight desc,
  30. t.create_date DESC
  31. </select>
  32. <select id="selectBuildingConsultants" resultType="java.util.HashMap">
  33. SELECT
  34. t.person_id AS id,
  35. u.user_name,
  36. u.org_name,
  37. u.department,
  38. u.position,
  39. u.phone,
  40. u.avatar,
  41. u.photo,
  42. u.description
  43. FROM
  44. ta_person t
  45. JOIN ta_person_building s USING (user_id)
  46. left join ta_user u on t.user_id = u.user_id
  47. WHERE
  48. s.building_id = #{buildingId}
  49. AND t.person_type = #{personType}
  50. AND t. STATUS = #{status}
  51. and t.org_id = #{orgId}
  52. and u.org_id = #{orgId}
  53. and u.status = 1
  54. ORDER BY u.weight desc,
  55. t.create_date DESC
  56. </select>
  57. <select id="getSalesExecutive" resultType="com.huiju.estateagents.entity.TaPerson">
  58. SELECT
  59. *
  60. FROM
  61. ta_person t
  62. WHERE
  63. t.person_type = 'Sales Executive'
  64. AND t.status = 1
  65. LIMIT 1
  66. </select>
  67. <select id="getPersonByOpenId" resultType="com.huiju.estateagents.entity.TaPerson">
  68. SELECT
  69. *
  70. FROM
  71. ta_person t
  72. WHERE
  73. t.mini_openid = #{openId}
  74. AND IFNULL(t.status, 0) &gt; -1
  75. </select>
  76. <update id="setFieldIncrement">
  77. UPDATE ta_person
  78. SET ${field} = IFNULL(${field}, 0) + #{increment}
  79. WHERE person_id = #{personId}
  80. </update>
  81. <update id="setPointsIncrement">
  82. UPDATE ta_person
  83. SET points = IFNULL(points, 0) + #{increment}
  84. WHERE person_id = #{personId}
  85. </update>
  86. <select id="selectCustomer" resultType="com.huiju.estateagents.entity.TaPerson">
  87. SELECT
  88. a.*,
  89. b.event as event,
  90. b.activity as activity,
  91. b.data as data,
  92. (select b.visit_time FROM ta_person_visit_record b where a.person_id = b.person_id ORDER BY b.visit_time desc LIMIT 1) as visitTime
  93. FROM
  94. ta_person a
  95. LEFT JOIN ta_person_visit_record b ON a.person_id = b.person_id
  96. WHERE
  97. a.person_type IS NULL
  98. ORDER BY create_date desc
  99. </select>
  100. <select id="getById" resultType="com.huiju.estateagents.entity.TaPerson">
  101. SELECT
  102. a.*
  103. FROM
  104. ta_person a
  105. WHERE
  106. a.person_id = #{personId}
  107. </select>
  108. <select id="getUserProjects" resultType="java.lang.String">
  109. SELECT
  110. b.building_name
  111. FROM
  112. ta_person_building a
  113. LEFT JOIN ta_building b ON a.building_id = b.building_id
  114. WHERE a.user_id = #{personId}
  115. </select>
  116. <select id="selectByIdPerson" resultType="com.huiju.estateagents.entity.TaPerson">
  117. select * from ta_person where mini_openid = #{openid};
  118. </select>
  119. <select id="getConsultantByName" resultType="java.lang.String">
  120. select person_id from ta_person where name like CONCAT('%',#{name}, '%')
  121. </select>
  122. <select id="getConsultantByTel" resultType="java.lang.String">
  123. select person_id from ta_person where tel = #{tel}
  124. </select>
  125. <select id="selectCardListofMine" resultType="java.util.HashMap">
  126. SELECT
  127. t.person_id AS id,
  128. t.name,
  129. t.company,
  130. t.department,
  131. t.post,
  132. t.user_id as userId,
  133. t.tel AS phone,
  134. t.avatarurl AS avatar,
  135. t.photo,
  136. u.description as description
  137. FROM
  138. ta_person t left join ta_user u on t.user_id = u.user_id
  139. WHERE
  140. t.person_type = #{personType}
  141. AND t.status = #{status}
  142. <if test="personIds != null">
  143. and t.person_id in
  144. <foreach collection="personIds" item="item" index="index" open="(" close=")" separator=",">
  145. #{item}
  146. </foreach>
  147. </if>
  148. ORDER BY
  149. u.weight desc,
  150. t.create_date DESC
  151. </select>
  152. <select id="selectRecentlyCount" resultType="integer" >
  153. SELECT
  154. COUNT(1) as activity_count
  155. FROM
  156. ta_person tp
  157. where tp.org_id = #{org} AND
  158. tp.person_type IN ('customer','drift','estate agent')
  159. <if test="startDate != null or endDate != null">
  160. AND tp.create_date BETWEEN #{startDate} and #{endDate}
  161. </if>
  162. <if test="startDate == null or endDate == null">
  163. AND tp.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
  164. </if>
  165. </select>
  166. <select id="selectUserBehavior" resultType="com.huiju.estateagents.po.PersonPO">
  167. SELECT
  168. temp_date.date as date,
  169. temp_date.type_name as activity,
  170. temp.activityCount as activityCount
  171. FROM
  172. (
  173. SELECT
  174. DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date, b.type_id, b.type_name
  175. from sequence a, td_biz_event_type b
  176. <trim prefix="where">
  177. <if test="startDate != null or endDate != null">
  178. a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
  179. </if>
  180. </trim>
  181. ) AS temp_date
  182. LEFT JOIN (
  183. SELECT
  184. COUNT(1) as activityCount,
  185. tpvr.event_type,
  186. DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' ) as date
  187. FROM
  188. ta_person tp
  189. INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
  190. where tp.org_id = #{org} AND tp.person_type IN ('customer','drift','estate agent')
  191. <if test="buildingId != null and buildingId != ''">
  192. and tpvr.building_id = #{buildingId}
  193. </if>
  194. <if test="eventType != null and eventType != ''">
  195. and tpvr.event_type = #{eventType}
  196. </if>
  197. <if test="event != null and event != ''">
  198. and tpvr.event = #{event}
  199. </if>
  200. <if test="activity != null and activity != ''">
  201. and tpvr.activity = #{activity}
  202. </if>
  203. GROUP BY tpvr.event_type, DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' )
  204. ) AS temp ON temp_date.date = temp.date and temp_date.type_id = temp.event_type
  205. order by temp_date.date asc
  206. </select>
  207. <select id="selectActiveUserCount" resultType="map">
  208. SELECT
  209. temp_date.date as date,
  210. sum(temp.activity_count) as activity_count,
  211. temp.visit_time as visit_time
  212. FROM
  213. (
  214. SELECT
  215. <if test="dateType == 'day'.toString()">
  216. DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
  217. </if>
  218. <if test="dateType == 'week'.toString()">
  219. DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum WEEK ), '%Y-%m-%d' ) AS date
  220. </if>
  221. <if test="dateType == 'month'.toString()">
  222. DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum MONTH ), '%Y-%m' ) AS date
  223. </if>
  224. FROM
  225. sequence a
  226. <trim prefix="where">
  227. <if test="startDate != null or endDate != null">
  228. a.rownum <![CDATA[ < ]]> datediff(#{endDate}, #{startDate})
  229. </if>
  230. <if test="startDate == null or endDate == null">
  231. a.rownum <![CDATA[ < ]]> 7
  232. </if>
  233. </trim>
  234. ) AS temp_date
  235. LEFT JOIN (
  236. SELECT
  237. COUNT(1) as activity_count,
  238. tpvr.max_visit_time AS visit_time
  239. FROM
  240. ta_person tp
  241. LEFT JOIN
  242. ( SELECT *, MAX(visit_time) as max_visit_time FROM ta_person_visit_record where org_id = #{org} GROUP BY person_id ) as tpvr
  243. ON tp.person_id = tpvr.person_id
  244. where tp.org_id = #{org} AND tp.person_type IN ('customer','drift','estate agent')
  245. GROUP BY DATE_FORMAT( tpvr.max_visit_time , '%Y-%m-%d' )
  246. ) AS temp ON
  247. <if test="dateType == 'month'.toString()">
  248. temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m' ) GROUP BY temp_date.date ORDER BY temp_date.date
  249. </if>
  250. <if test="dateType == 'day'.toString()">
  251. temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' ) GROUP BY temp_date.date ORDER BY temp_date.date
  252. </if>
  253. </select>
  254. <select id="selectNewsUserCount" resultType="map">
  255. SELECT
  256. authorization_count_table.date as date,
  257. ifnull(authorization_count_table.authorization_count, 0) as authorization_count,
  258. ifnull(user_count_table.user_count, 0) as user_count
  259. FROM
  260. (
  261. SELECT
  262. *
  263. FROM
  264. (
  265. SELECT
  266. DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
  267. FROM
  268. sequence a
  269. <trim prefix="where">
  270. <if test="startDate != null or endDate != null">
  271. a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
  272. </if>
  273. </trim>
  274. ) AS temp_date
  275. LEFT JOIN (
  276. SELECT
  277. COUNT(1) as authorization_count,
  278. tp.create_date as create_date
  279. FROM
  280. ta_person tp
  281. where tp.person_type IN ('customer','drift','estate agent') and tp.org_id = #{orgId}
  282. and tp.phone is NOT NULL
  283. <if test="startDate != null or endDate != null">
  284. AND tp.create_date BETWEEN #{startDate} and #{endDate}
  285. </if>
  286. <if test="startDate == null or endDate == null">
  287. AND tp.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
  288. </if>
  289. GROUP BY DATE_FORMAT( tp.create_date , '%Y-%m-%d' )
  290. ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
  291. ) as authorization_count_table
  292. ,
  293. (
  294. SELECT
  295. *
  296. FROM
  297. (
  298. SELECT
  299. DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
  300. FROM
  301. sequence a
  302. <trim prefix="where">
  303. <if test="startDate != null or endDate != null">
  304. a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
  305. </if>
  306. </trim>
  307. ) AS temp_date
  308. LEFT JOIN (
  309. SELECT
  310. COUNT(1) as user_count,
  311. tp.create_date as create_date
  312. FROM
  313. ta_person tp
  314. where tp.person_type IN ('customer','drift','estate agent') and tp.org_id = #{orgId}
  315. <if test="startDate != null or endDate != null">
  316. AND tp.create_date BETWEEN #{startDate} and #{endDate}
  317. </if>
  318. <if test="startDate == null or endDate == null">
  319. AND tp.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
  320. </if>
  321. GROUP BY DATE_FORMAT( tp.create_date , '%Y-%m-%d' )
  322. ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
  323. ) as user_count_table
  324. where
  325. user_count_table.date = authorization_count_table.date
  326. GROUP BY date
  327. </select>
  328. <select id="selectUserSourcePie" resultType="integer">
  329. select count(1)
  330. FROM ta_person
  331. WHERE org_id = #{org} AND person_type IN ('customer','drift','estate agent')
  332. <if test="recommendPersonType != null and recommendPersonType != ''">
  333. and recommend_person_type = #{recommendPersonType}
  334. </if>
  335. </select>
  336. <select id="selectUserSourceColumnar" resultType="map">
  337. SELECT
  338. tpf.from_name as from_name,
  339. (
  340. SELECT
  341. COUNT(1)
  342. FROM ta_person tps
  343. LEFT JOIN td_person_from tpfs
  344. ON tps.from_code = tpfs.from_code
  345. WHERE tpfs.from_code = tpf.from_code and tps.phone is NOT NULL
  346. AND tps.org_id = #{org}
  347. and tps.person_type IN ('customer','drift','estate agent')
  348. <if test="startDate != null or endDate != null">
  349. and tps.create_date BETWEEN #{startDate} and #{endDate}
  350. </if>
  351. <if test="startDate == null or endDate == null">
  352. and tps.create_date BETWEEN DATE_SUB( tps.create_date, INTERVAL 7 DAY ) and now()
  353. </if>
  354. ) as registered,
  355. (
  356. SELECT
  357. COUNT(1)
  358. FROM ta_person tps
  359. LEFT JOIN td_person_from tpfs
  360. ON tps.from_code = tpfs.from_code
  361. WHERE tpfs.from_code = tpf.from_code
  362. AND tps.org_id = #{org}
  363. and tps.person_type IN ('customer','drift','estate agent')
  364. <if test="startDate != null or endDate != null">
  365. and tps.create_date BETWEEN #{startDate} and #{endDate}
  366. </if>
  367. <if test="startDate == null or endDate == null">
  368. and tps.create_date BETWEEN DATE_SUB( tps.create_date, INTERVAL 7 DAY ) and now()
  369. </if>
  370. ) as user_count
  371. FROM td_person_from tpf
  372. LEFT JOIN ta_person tp
  373. ON tp.from_code = tpf.from_code
  374. where tp.org_id = #{org} AND tp.person_type IN ('customer','drift','estate agent')
  375. GROUP BY tpf.from_code
  376. </select>
  377. <select id="selectUserSourceData" resultType="map">
  378. select
  379. temp_date.date AS date,
  380. temp_date.from_name as from_name,
  381. temp_date.from_code as from_code,
  382. IFNULL(user_count.count, 0) as count,
  383. IFNULL(registered_count.count,0) as registered,
  384. user_count.create_date as create_date
  385. FROM
  386. (
  387. SELECT
  388. DATE_FORMAT( DATE_SUB( <if test="endDate != null">#{endDate}</if><if test="endDate == null">now()</if>, INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
  389. tempf.from_name as from_name,
  390. tempf.from_code as from_code
  391. FROM
  392. sequence a
  393. ,
  394. td_person_from tempf
  395. <trim prefix="where">
  396. <if test="startDate != null or endDate != null">
  397. a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
  398. </if>
  399. </trim>
  400. ) AS temp_date
  401. LEFT JOIN
  402. (
  403. SELECT
  404. ifnull(COUNT(1), 0) as count,
  405. DATE_FORMAT( tps.create_date, '%Y-%m-%d' ) as create_date,
  406. tpfs.from_code as from_code,
  407. tpfs.from_name as from_name
  408. FROM ta_person tps
  409. LEFT JOIN td_person_from tpfs
  410. ON tps.from_code = tpfs.from_code
  411. WHERE tpfs.from_code = tps.from_code
  412. AND tps.org_id = #{org}
  413. and tps.person_type IN ('customer','drift','estate agent')
  414. AND tps.create_date BETWEEN #{startDate} AND #{endDate}
  415. GROUP BY tpfs.from_code, DATE_FORMAT( tps.create_date, '%Y-%m-%d' )
  416. ) as user_count
  417. ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') = temp_date.date and temp_date.from_code = user_count.from_code
  418. LEFT JOIN
  419. (
  420. SELECT
  421. ifnull(COUNT(1), 0) as count,
  422. DATE_FORMAT( tps.create_date, '%Y-%m-%d' ) as create_date,
  423. tpfs.from_code as from_code,
  424. tpfs.from_name as from_name
  425. FROM ta_person tps
  426. LEFT JOIN td_person_from tpfs
  427. ON tps.from_code = tpfs.from_code
  428. WHERE tpfs.from_code = tps.from_code
  429. AND tps.org_id = #{org}
  430. and tps.person_type IN ('customer','drift','estate agent')
  431. AND tps.create_date BETWEEN #{startDate} AND #{endDate}
  432. and tps.phone is not null
  433. GROUP BY tpfs.from_code,DATE_FORMAT( tps.create_date, '%Y-%m-%d' )
  434. ) as registered_count
  435. ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') = temp_date.date and temp_date.from_code = registered_count.from_code
  436. order by temp_date.date DESC
  437. </select>
  438. <select id="getPersonList" resultType="com.huiju.estateagents.entity.TaPerson">
  439. SELECT
  440. a.*
  441. FROM
  442. ta_person a
  443. LEFT JOIN ta_person_building b ON a.person_id = b.person_id
  444. <where>
  445. 1=1
  446. <if test="personType != null and personType!= ''">
  447. and a.person_type = #{personType}
  448. </if>
  449. <if test="name != null and name!= ''">
  450. and a.name like CONCAT('%',#{name}, '%')
  451. </if>
  452. <if test="personTags != null and personTags!= ''">
  453. and a.person_tags like CONCAT('%',#{personTags}, '%')
  454. </if>
  455. <if test="phone != null and phone!= ''">
  456. and a.tel = #{phone}
  457. </if>
  458. <if test="buildingId != null and buildingId!= ''">
  459. and b.building_id = #{buildingId}
  460. </if>
  461. <if test="status != null">
  462. and a.status = #{status}
  463. </if>
  464. </where>
  465. GROUP BY a.person_id
  466. </select>
  467. <select id="channelBrokerList" resultType="com.huiju.estateagents.entity.TaPerson">
  468. select
  469. p.*,
  470. COUNT(rc.person_id) AS recommendCount
  471. from ta_channel_person tch
  472. left join ta_person p on tch.person_id = p.person_id
  473. LEFT JOIN ta_recommend_customer rc ON p.person_id = rc.person_id
  474. <where>
  475. <if test="name !=null and name !=''">
  476. and rc.name like CONCAT('%',#{name}, '%')
  477. </if>
  478. <if test="phone !=null and phone !=''">
  479. and rc.phone like CONCAT('%',#{phone}, '%')
  480. </if>
  481. and p.org_id= #{orgid}
  482. and tch.channel_id = #{channelId}
  483. </where>
  484. GROUP BY tch.person_id
  485. </select>
  486. <select id="InviteClientsList" resultType="com.huiju.estateagents.entity.TaPerson">
  487. select * from ta_person WHERE recommend_agent = #{id}
  488. </select>
  489. <select id="sumPointsByOrgId" resultType="java.lang.Integer">
  490. select sum(points) from ta_person t where 1 = 1
  491. <if test="orgId">
  492. and t.org_id = #{orgId}
  493. </if>
  494. </select>
  495. <update id="upDatePersonCityToId">
  496. UPDATE ta_person a
  497. INNER JOIN (
  498. SELECT
  499. t.*, s.shortname AS province
  500. FROM
  501. td_city t
  502. INNER JOIN td_city s ON t.parentid = s.id
  503. ) b ON a.city = b.shortname
  504. AND a.province = b.province
  505. set a.city = b.id
  506. where a.city IS NOT NULL
  507. and (a.city REGEXP '[^0-9.]')=1
  508. and a.person_id = #{personId}
  509. </update>
  510. <select id="judgeBindStatusByCondition" resultType="java.lang.Integer">
  511. select count(1) from ta_user a
  512. LEFT JOIN ta_person b on a.user_id = b.user_id
  513. where a.org_id = #{orgId} and b.user_id = #{userId} and a.phone = #{phone}
  514. </select>
  515. <select id="selectDriftCustomerPageList" resultType="com.huiju.estateagents.entity.TaPerson">
  516. SELECT
  517. t.* ,d.scene_type,d.scene_alias
  518. FROM
  519. ta_person t
  520. LEFT JOIN ta_person_from_record r ON t.person_id = r.person_id AND r.is_first_time = 1 and r.org_id = #{orgId}
  521. left join td_wx_dict d on r.scene_id = d.scene_id
  522. WHERE
  523. t.org_id = #{orgId}
  524. and t.person_type = #{personEstateDrift}
  525. <if test="buildingId !=null and buildingId !=''">
  526. and t.building_id = #{buildingId}
  527. </if>
  528. <if test="sceneType !=null and sceneType !=''">
  529. and d.scene_type = #{sceneType}
  530. </if>
  531. order by t.create_date desc
  532. </select>
  533. <select id="selectFromNum" resultType="java.lang.Integer">
  534. SELECT
  535. count( 1 )
  536. FROM
  537. (
  538. SELECT
  539. t.from_record_id,
  540. t.person_id
  541. FROM
  542. ta_person_from_record t
  543. LEFT JOIN ta_person p ON t.share_person_id = p.person_id
  544. WHERE t.is_first_time = 1
  545. and t.org_id = #{orgId}
  546. <if test="personType !=null and personType !=''">
  547. and p.person_type = #{personType}
  548. </if>
  549. GROUP BY t.person_id) d
  550. </select>
  551. <select id="selectTodayRecentlyCount" resultType="java.lang.Integer">
  552. SELECT
  553. COUNT(1) as activity_count
  554. FROM
  555. ta_person tp
  556. where tp.org_id = #{orgId} AND
  557. tp.person_type IN ('customer','drift','estate agent')
  558. AND DATE_FORMAT(tp.create_date,'%Y-%m-%d') = DATE_FORMAT(#{nowDate},'%Y-%m-%d')
  559. </select>
  560. <insert id="savePersonPosition" parameterType="com.huiju.estateagents.entity.TaPersonPositon">
  561. insert into ta_person_position
  562. <trim prefix="(" suffix=")" suffixOverrides=",">
  563. <if test="id != null">
  564. id,
  565. </if>
  566. <if test="personId != null">
  567. person_id,
  568. </if>
  569. <if test="lon != null">
  570. lon,
  571. </if>
  572. <if test="lat != null">
  573. lat,
  574. </if>
  575. <if test="citycode != null">
  576. citycode,
  577. </if>
  578. <if test="country != null">
  579. country,
  580. </if>
  581. <if test="province != null">
  582. province,
  583. </if>
  584. <if test="city != null">
  585. city,
  586. </if>
  587. <if test="district != null">
  588. district,
  589. </if>
  590. <if test="address != null">
  591. address,
  592. </if>
  593. <if test="createTime != null">
  594. create_time,
  595. </if>
  596. </trim>
  597. <trim prefix="values (" suffix=")" suffixOverrides=",">
  598. <if test="id != null">
  599. #{id,jdbcType=INTEGER},
  600. </if>
  601. <if test="personId != null">
  602. #{personId,jdbcType=INTEGER},
  603. </if>
  604. <if test="lon != null">
  605. #{lon,jdbcType=VARCHAR},
  606. </if>
  607. <if test="lat != null">
  608. #{lat,jdbcType=VARCHAR},
  609. </if>
  610. <if test="citycode != null">
  611. #{citycode},
  612. </if>
  613. <if test="country != null">
  614. #{country},
  615. </if>
  616. <if test="province != null">
  617. #{province},
  618. </if>
  619. <if test="city != null">
  620. #{city},
  621. </if>
  622. <if test="district != null">
  623. #{district},
  624. </if>
  625. <if test="address != null">
  626. #{address},
  627. </if>
  628. <if test="createTime != null">
  629. #{createTime}
  630. </if>
  631. </trim>
  632. </insert>
  633. </mapper>