CusFollowMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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.dk.mdm.mapper.mst.CusFollowMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. follow_id, cus_id, follow_status, follow_org, follow_staff, follow_time, follow_data, follow_time_len, stay_time_len, intention, invite_result, invite_time, design_staff, next_follow_plan, next_follow_time, annex_paths, measure_status, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  8. </sql>
  9. <sql id="Base_Column_List_Join">
  10. tccf.follow_id, tccf.cus_id, tccf.follow_status,tccf.follow_type, tccf.follow_org, tccf.follow_staff, tccf.follow_time, tccf.follow_data,
  11. tccf.follow_time_len, tccf.stay_time_len, tccf.intention, tccf.invite_result, tccf.invite_time, tccf.design_staff,
  12. tccf.next_follow_plan, tccf.next_follow_time,tccf.annex_paths, tccf.measure_status, tccf.remarks, tccf.flg_valid,
  13. tccf.cp_id
  14. </sql>
  15. <!-- 通用查询映射结果 -->
  16. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.CusFollow">
  17. <id column="follow_id" property="followId"/>
  18. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  19. <result column="follow_status" property="followStatus"/>
  20. <result column="follow_org" property="followOrg" typeHandler="UuidTypeHandler"/>
  21. <result column="follow_staff" property="followStaff" typeHandler="UuidTypeHandler"/>
  22. <result column="follow_time" property="followTime" typeHandler="TimestampTypeHandler"/>
  23. <result column="follow_data" property="followData"/>
  24. <result column="follow_time_len" property="followTimeLen"/>
  25. <result column="stay_time_len" property="stayTimeLen"/>
  26. <result column="intention" property="intention"/>
  27. <result column="invite_result" property="inviteResult"/>
  28. <result column="invite_time" property="inviteTime" typeHandler="TimestampTypeHandler"/>
  29. <result column="design_staff" property="designStaff" typeHandler="UuidTypeHandler"/>
  30. <result column="next_follow_plan" property="nextFollowPlan"/>
  31. <result column="next_follow_time" property="nextFollowTime" typeHandler="TimestampTypeHandler"/>
  32. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  33. <result column="measure_status" property="measureStatus"/>
  34. <result column="remarks" property="remarks"/>
  35. <result column="flg_valid" property="flgValid"/>
  36. <result column="cp_id" property="cpId"/>
  37. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  38. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  39. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  40. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  41. <result column="op_app_code" property="opAppCode"/>
  42. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  43. <result column="op_db_user" property="opDbUser"/>
  44. </resultMap>
  45. <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mst.CusFollowResponse">
  46. <id column="follow_id" property="followId"/>
  47. <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
  48. <result column="follow_status" property="followStatus"/>
  49. <result column="follow_type" property="followType"/>
  50. <result column="follow_org" property="followOrg" typeHandler="UuidTypeHandler"/>
  51. <result column="follow_staff" property="followStaff" typeHandler="UuidTypeHandler"/>
  52. <result column="follow_time" property="followTime" typeHandler="TimestampTypeHandler"/>
  53. <result column="follow_data" property="followData"/>
  54. <result column="follow_time_len" property="followTimeLen"/>
  55. <result column="stay_time_len" property="stayTimeLen"/>
  56. <result column="intention" property="intention"/>
  57. <result column="invite_result" property="inviteResult"/>
  58. <result column="invite_time" property="inviteTime" typeHandler="TimestampTypeHandler"/>
  59. <result column="design_staff" property="designStaff" typeHandler="UuidTypeHandler"/>
  60. <result column="next_follow_plan" property="nextFollowPlan"/>
  61. <result column="next_follow_time" property="nextFollowTime" typeHandler="TimestampTypeHandler"/>
  62. <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
  63. <result column="measure_status" property="measureStatus"/>
  64. <result column="measure_status_name" property="measureStatusName"/>
  65. <result column="remarks" property="remarks"/>
  66. <result column="flg_valid" property="flgValid"/>
  67. <result column="cp_id" property="cpId"/>
  68. <result column="sale_status" property="saleStatus"/>
  69. <result column="channel_id" property="channelId"/>
  70. <result column="cusName" property="cusName"/>
  71. <result column="cusCode" property="cusCode"/>
  72. <result column="cusPhone" property="cusPhone"/>
  73. <result column="orgName" property="orgName"/>
  74. <result column="staffName" property="staffName"/>
  75. <result column="follow_count" property="followCount"/>
  76. <result column="follow_staff_name" property="followStaffName"/>
  77. <result column="create_time" property="createTime" typeHandler="TimestampTypeHandler"/>
  78. <result column="follow_status_name" property="followStatusName"/>
  79. <result column="cus_name" property="cusName"/>
  80. <result column="cus_code" property="cusCode"/>
  81. <result column="cus_phone" property="cusPhone"/>
  82. <result column="address_full" property="addressFull"/>
  83. <result column="address_no" property="addressNo"/>
  84. <result column="address_name" property="addressName"/>
  85. <result column="intention_name" property="intentionName"/>
  86. <result column="stay_time_len_name" property="stayTimeLenName"/>
  87. <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
  88. <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
  89. </resultMap>
  90. <!-- 通用条件列 -->
  91. <sql id="Condition">
  92. <where>
  93. <if test="cusId != null and cusId != ''">
  94. AND cus_id = #{cusId}
  95. </if>
  96. <if test="followStatus != null and followStatus != ''">
  97. AND follow_status = #{followStatus}
  98. </if>
  99. <if test="followOrg != null and followOrg != ''">
  100. AND follow_org = #{followOrg}
  101. </if>
  102. <if test="followStaff != null and followStaff != ''">
  103. AND follow_staff = #{followStaff}
  104. </if>
  105. <if test="followTime != null">
  106. AND follow_time = #{followTime}
  107. </if>
  108. <if test="followData != null and followData != ''">
  109. AND follow_data = #{followData}
  110. </if>
  111. <if test="followTimeLen != null">
  112. AND follow_time_len = #{followTimeLen}
  113. </if>
  114. <if test="stayTimeLen != null and stayTimeLen != ''">
  115. AND stay_time_len = #{stayTimeLen}
  116. </if>
  117. <if test="intention != null and intention != ''">
  118. AND intention = #{intention}
  119. </if>
  120. <if test="inviteResult != null and inviteResult != ''">
  121. AND invite_result = #{inviteResult}
  122. </if>
  123. <if test="inviteTime != null">
  124. AND invite_time = #{inviteTime}
  125. </if>
  126. <if test="designStaff != null and designStaff != ''">
  127. AND design_staff = #{designStaff}
  128. </if>
  129. <if test="nextFollowPlan != null and nextFollowPlan != ''">
  130. AND next_follow_plan = #{nextFollowPlan}
  131. </if>
  132. <if test="nextFollowTime != null">
  133. AND next_follow_time = #{nextFollowTime}
  134. </if>
  135. <if test="annexPaths != null and annexPaths != ''">
  136. AND annex_paths = #{annexPaths}
  137. </if>
  138. <if test="measureStatus != null and measureStatus != ''">
  139. AND measure_status = #{measureStatus}
  140. </if>
  141. <if test="remarks != null and remarks != ''">
  142. AND remarks = #{remarks}
  143. </if>
  144. <if test="flgValid != null">
  145. AND flg_valid = #{flgValid}
  146. </if>
  147. <if test="cpId != null">
  148. AND cp_id = #{cpId}
  149. </if>
  150. <if test="opCreateTime != null">
  151. AND op_create_time = #{opCreateTime}
  152. </if>
  153. <if test="opCreateUserId != null and opCreateUserId != ''">
  154. AND op_create_user_id = #{opCreateUserId}
  155. </if>
  156. <if test="opUpdateTime != null">
  157. AND op_update_time = #{opUpdateTime}
  158. </if>
  159. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  160. AND op_update_user_id = #{opUpdateUserId}
  161. </if>
  162. <if test="opAppCode != null and opAppCode != ''">
  163. AND op_app_code = #{opAppCode}
  164. </if>
  165. <if test="opTimestamp != null">
  166. AND op_timestamp = #{opTimestamp}
  167. </if>
  168. <if test="opDbUser != null and opDbUser != ''">
  169. AND op_db_user = #{opDbUser}
  170. </if>
  171. </where>
  172. </sql>
  173. <sql id="Condition_Join">
  174. <where>
  175. <if test="cusId != null and cusId != ''">
  176. AND tccf.cus_id = #{cusId}::uuid
  177. </if>
  178. <if test="followStatus != null and followStatus != ''">
  179. AND tccf.follow_status = #{followStatus}
  180. </if>
  181. <if test="followId != null and followId != ''">
  182. AND tccf.follow_id = #{followId}::uuid
  183. </if>
  184. <if test="followOrg != null and followOrg != ''">
  185. AND tccf.follow_org = #{followOrg}
  186. </if>
  187. <if test="followStaff != null and followStaff != ''">
  188. AND tccf.follow_staff = #{followStaff}
  189. </if>
  190. <if test="followTime != null">
  191. AND tccf.follow_time = #{followTime}
  192. </if>
  193. <if test="followData != null and followData != ''">
  194. AND tccf.follow_data = #{followData}
  195. </if>
  196. <if test="followTimeLen != null">
  197. AND tccf.follow_time_len = #{followTimeLen}
  198. </if>
  199. <if test="stayTimeLen != null and stayTimeLen != ''">
  200. AND tccf.stay_time_len = #{stayTimeLen}
  201. </if>
  202. <if test="intention != null and intention != ''">
  203. AND tccf.intention = #{intention}
  204. </if>
  205. <if test="inviteResult != null and inviteResult != ''">
  206. AND tccf.invite_result = #{inviteResult}
  207. </if>
  208. <if test="inviteTime != null">
  209. AND tccf.invite_time = #{inviteTime}
  210. </if>
  211. <if test="designStaff != null and designStaff != ''">
  212. AND tccf.design_staff = #{designStaff}
  213. </if>
  214. <if test="nextFollowPlan != null and nextFollowPlan != ''">
  215. AND tccf.next_follow_plan = #{nextFollowPlan}
  216. </if>
  217. <!-- <if test="nextFollowTime != null">-->
  218. <!-- AND tccf.next_follow_time = #{nextFollowTime}-->
  219. <!-- </if>-->
  220. <if test="annexPaths != null and annexPaths != ''">
  221. AND tccf.annex_paths = #{annexPaths}
  222. </if>
  223. <if test="measureStatus != null and measureStatus != ''">
  224. AND tccf.measure_status = #{measureStatus}
  225. </if>
  226. <if test="remarks != null and remarks != ''">
  227. AND tccf.remarks = #{remarks}
  228. </if>
  229. <if test="flgValid != null">
  230. AND tccf.flg_valid = #{flgValid}
  231. </if>
  232. <if test="cpId != null">
  233. AND tccf.cp_id = #{cpId}
  234. </if>
  235. <if test="staffIds != null and staffIds.size()>0">
  236. AND tccf.follow_staff =
  237. any(#{staffIds, typeHandler=StringListTypeHandler})
  238. </if>
  239. <if test="followStatusList != null and followStatusList.size()>0">
  240. AND tccf.follow_status =
  241. any(#{followStatusList, typeHandler=StringListTypeHandler})
  242. </if>
  243. <if test="createtimeStart != null and createtimeEnd != null">
  244. AND tccf.op_create_time &gt;= #{createtimeStart}::timestamp with time zone
  245. AND tccf.op_create_time &lt; #{createtimeEnd}::timestamp with time zone + interval '1 day'
  246. </if>
  247. <if test="nextFollowTimeStart != null and nextFollowTimeEnd != null">
  248. AND tccf.next_follow_time &gt;= #{nextFollowTimeStart}::timestamp with time zone
  249. AND tccf.next_follow_time &lt; #{nextFollowTimeEnd}::timestamp with time zone + interval '1 day'
  250. </if>
  251. <if test="searchText != null and searchText != ''">
  252. AND(tmc.cus_phone LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  253. OR tmc.cus_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  254. OR tmc.address_full LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  255. OR tccf.remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%')
  256. )
  257. </if>
  258. </where>
  259. </sql>
  260. <sql id="idsForeach">
  261. <!-- 根据主键followId批量操作 -->
  262. WHERE follow_id in
  263. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  264. #{item}
  265. </foreach>
  266. </sql>
  267. <!-- 查询表t_crm_cus_follow,(条件查询+分页)列表 -->
  268. <select id="selectByCond" resultMap="BaseResultMapResponse">
  269. SELECT
  270. <include refid="Base_Column_List_Join"/>,
  271. (CASE
  272. WHEN tccf.follow_status = '跟进状态-接待' THEN '无联系人'
  273. ELSE tmc.cus_name END ) AS cus_name,
  274. tmc.cus_code as cus_code,
  275. tmc.cus_phone AS cus_phone,
  276. tmc.sale_status AS sale_status,
  277. tmc.channel_id AS channel_id,
  278. tmc.address_full AS address_full,
  279. tmc.address_area AS address_area,
  280. tmc.address_gcj02 AS address_gcj02,
  281. tmc.address_name AS address_name,
  282. tmc.address_no AS address_no,
  283. tmo.org_name AS "orgName",
  284. tms.staff_name AS "staffName",
  285. tmc.follow_count AS follow_count,
  286. <if test="measureStatus != null and measureStatus != ''">
  287. tcmr.measure_status AS "measureStatus",
  288. tdk4.kind_name_i18n ->> #{i18n} AS "measure_status_name",
  289. </if>
  290. tdk1.kind_name_i18n ->> #{i18n} AS "follow_status_name",
  291. tdk2.kind_name_i18n ->> #{i18n} AS intention_name,
  292. tdk3.kind_name_i18n ->> #{i18n} AS stay_time_len_name
  293. FROM dkic_b.t_crm_cus_follow tccf
  294. <if test="measureStatus != null and measureStatus != ''">
  295. LEFT JOIN dkic_b.t_crm_measure_receipt tcmr ON tcmr.cus_id = tccf.cus_id and tcmr.measure_status = #{measureStatus}
  296. LEFT JOIN sys.t_data_kind tdk4 on tdk4.kind_code = tcmr.measure_status
  297. </if>
  298. LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
  299. LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tccf.follow_org
  300. LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tccf.follow_staff
  301. LEFT JOIN sys.t_data_kind tdk1 on tdk1.kind_code = tccf.follow_status
  302. LEFT JOIN sys.t_data_kind tdk2 on tdk2.kind_code = tccf.intention
  303. LEFT JOIN sys.t_data_kind tdk3 on tdk3.kind_code = tccf.stay_time_len
  304. <include refid="Condition_Join"/>
  305. order by tccf.follow_time desc
  306. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  307. limit #{end} offset #{start}
  308. </if>
  309. </select>
  310. <!--查询跟进记录-->
  311. <select id="selectByList" resultMap="BaseResultMapResponse">
  312. SELECT
  313. <include refid="Base_Column_List_Join"/>,
  314. tmc.cus_name AS "cusName",
  315. tmc.cus_code as "cusCode",
  316. tmc.cus_phone AS "cusPhone",
  317. tmc.address_full AS "addressFull",
  318. tmo.org_name AS "orgName",
  319. tms.staff_name AS "staffName",
  320. tmc.follow_count AS follow_count,
  321. tms.staff_name AS follow_staff_name,
  322. tccf.op_create_time AS create_time,
  323. tdk1.kind_name_i18n ->> #{i18n} AS "follow_status_name"
  324. FROM dkic_b.t_crm_cus_follow tccf
  325. LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
  326. LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tccf.follow_org
  327. LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tccf.follow_staff
  328. LEFT JOIN sys.t_data_kind tdk1 on tdk1.kind_code = tccf.follow_status
  329. <include refid="Condition_Join"/>
  330. ORDER BY tccf.op_create_time DESC
  331. </select>
  332. <!-- 查询表t_crm_cus_follow,(条件查询)个数 -->
  333. <select id="countByCond" resultType="Long">
  334. SELECT
  335. count(1)
  336. FROM dkic_b.t_crm_cus_follow tccf
  337. LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
  338. <include refid="Condition_Join"/>
  339. </select>
  340. <!-- 根据主键查询表t_crm_cus_follow的一行数据 -->
  341. <select id="selectById" resultMap="BaseResultMap">
  342. SELECT
  343. <include refid="Base_Column_List"/>
  344. FROM dkic_b.t_crm_cus_follow
  345. WHERE follow_id = #{id}::uuid
  346. </select>
  347. <!-- 根据主键锁定表t_crm_cus_follow的一行数据 -->
  348. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  349. SELECT
  350. <include refid="Base_Column_List"/>
  351. FROM dkic_b.t_crm_cus_follow
  352. WHERE follow_id = #{followId}
  353. for update
  354. </select>
  355. <!-- 根据主键锁定表t_crm_cus_follow的多行数据 -->
  356. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  357. SELECT
  358. <include refid="Base_Column_List"/>
  359. FROM dkic_b.t_crm_cus_follow
  360. <include refid="idsForeach"/>
  361. for update
  362. </select>
  363. <insert id="insertBatch">
  364. insert into dkic_b.t_crm_cus_follow
  365. (
  366. <trim suffixOverrides=",">
  367. cus_id,
  368. follow_status,
  369. follow_org,
  370. follow_staff,
  371. follow_time,
  372. follow_data,
  373. follow_time_len,
  374. stay_time_len,
  375. intention,
  376. invite_result,
  377. invite_time,
  378. design_staff,
  379. next_follow_plan,
  380. next_follow_time,
  381. annex_paths,
  382. measure_status,
  383. remarks,
  384. cp_id,
  385. op_app_code,
  386. </trim>
  387. )
  388. values
  389. <foreach collection="list" index="index" item="item" separator=",">
  390. (
  391. <trim suffixOverrides=",">
  392. #{item.cusId}::uuid,
  393. #{item.followStatus},
  394. #{item.followOrg}::uuid,
  395. #{item.followStaff}::uuid,
  396. #{item.followTime},
  397. #{item.followData},
  398. #{item.followTimeLen},
  399. #{item.stayTimeLen},
  400. #{item.intention},
  401. #{item.inviteResult},
  402. #{item.inviteTime},
  403. #{item.designStaff}::uuid,
  404. #{item.nextFollowPlan},
  405. #{item.nextFollowTime},
  406. #{item.annexPaths},
  407. #{item.measureStatus},
  408. #{item.remarks},
  409. #{item.cpId},
  410. #{item.opAppCode},
  411. </trim>
  412. )
  413. </foreach>
  414. </insert>
  415. <select id="selectCusFollow" resultType="map">
  416. (
  417. SELECT
  418. tccf.follow_id AS "followId",
  419. tccf.cus_id AS "cusId",
  420. tccf.follow_status AS "followStatus",
  421. tccf.follow_type AS "followType",
  422. tccf.follow_org AS "followOrg",
  423. tccf.follow_staff AS "followStaff",
  424. tccf.follow_time AS "followTime",
  425. tccf.follow_data AS "followData",
  426. tccf.follow_time_len AS "followTimeLen",
  427. tccf.stay_time_len AS "stayTimeLen",
  428. tccf.intention AS "intention",
  429. tccf.invite_result AS "inviteResult",
  430. tccf.invite_time AS "inviteTime",
  431. tccf.design_staff AS "designStaff",
  432. tccf.next_follow_plan AS "nextFollowPlan",
  433. tccf.next_follow_time AS "nextFollowTime",
  434. tccf.measure_status AS "measureStatus",
  435. tmc.follow_count AS "followCount",
  436. tms.staff_name AS "followStaffName",
  437. tccf.op_create_time AS "createTime",
  438. tdk1.kind_name_i18n ->> #{i18n} AS "followStatusName",
  439. tdk2.kind_name_i18n ->> #{i18n} AS "followTypeName"
  440. FROM
  441. dkic_b.t_crm_cus_follow tccf
  442. LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
  443. LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = tccf.follow_staff
  444. LEFT JOIN sys.t_data_kind tdk1 ON tdk1.kind_code = tccf.follow_status
  445. LEFT JOIN sys.t_data_kind tdk2 ON tdk1.kind_code = tccf.follow_type
  446. WHERE
  447. tccf.cus_id = #{cusId}::uuid
  448. )
  449. UNION ALL
  450. (
  451. SELECT
  452. tcmr.follow_id AS "followId",
  453. tcmr.cus_id AS "cusId",
  454. tccf1.follow_status AS "followStatus",
  455. tccf1.follow_type AS "followType",
  456. tccf1.follow_org AS "followOrg",
  457. tccf1.follow_staff AS "followStaff",
  458. tccf1.follow_time AS "followTime",
  459. tccf1.follow_data AS "followData",
  460. tccf1.follow_time_len AS "followTimeLen",
  461. tccf1.stay_time_len AS "stayTimeLen",
  462. tccf1.intention AS "intention",
  463. tccf1.invite_result AS "inviteResult",
  464. tccf1.invite_time AS "inviteTime",
  465. tccf1.design_staff AS "designStaff",
  466. tccf1.next_follow_plan AS "nextFollowPlan",
  467. tccf1.next_follow_time AS "nextFollowTime",
  468. tcmr.measure_status AS "measureStatus",
  469. tmc.follow_count AS "followCount",
  470. tms.staff_name AS "followStaffName",
  471. tcmr.op_create_time AS "createTime",
  472. tdk1.kind_name_i18n ->> #{i18n} AS "followStatusName",
  473. tdk2.kind_name_i18n ->> #{i18n} AS "followTypeName"
  474. FROM
  475. dkic_b.t_crm_measure_receipt tcmr
  476. LEFT JOIN sys.t_data_kind tdk1 ON tdk1.kind_code = tcmr.measure_status
  477. LEFT JOIN dkic_b.t_crm_cus_follow tccf1 ON tccf1.follow_id = tcmr.follow_id
  478. LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf1.cus_id
  479. LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = tccf1.follow_staff
  480. LEFT JOIN sys.t_data_kind tdk2 ON tdk1.kind_code = tccf1.follow_type
  481. WHERE
  482. tcmr.cus_id = #{cusId}::uuid
  483. )
  484. ORDER BY
  485. "createTime" DESC;
  486. </select>
  487. </mapper>