CrmCustomerMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.crm.mapper.CrmCustomerMapper">
  6. <resultMap type="CrmCustomer" id="CrmCustomerResult">
  7. <result property="customerId" column="customer_id" />
  8. <result property="customerCode" column="customer_code" />
  9. <result property="customerName" column="customer_name" />
  10. <result property="mobile" column="mobile" />
  11. <result property="sex" column="sex" />
  12. <result property="weixin" column="weixin" />
  13. <result property="remark" column="remark" />
  14. <result property="userId" column="user_id" />
  15. <result property="createUserId" column="create_user_id" />
  16. <result property="receiveUserId" column="receive_user_id" />
  17. <result property="customerUserId" column="customer_user_id" />
  18. <result property="address" column="address" />
  19. <result property="cityIds" column="city_ids" />
  20. <result property="location" column="location" />
  21. <result property="detailAddress" column="detail_address" />
  22. <result property="lng" column="lng" />
  23. <result property="lat" column="lat" />
  24. <result property="createTime" column="create_time" />
  25. <result property="updateTime" column="update_time" />
  26. <result property="status" column="status" />
  27. <result property="isReceive" column="is_receive" />
  28. <result property="deptId" column="dept_id" />
  29. <result property="isDel" column="is_del" />
  30. <result property="customerType" column="customer_type" />
  31. <result property="receiveTime" column="receive_time" />
  32. <result property="poolTime" column="pool_time" />
  33. <result property="companyId" column="company_id" />
  34. <result property="isLine" column="is_line" />
  35. <result property="source" column="source" />
  36. <result property="tags" column="tags" />
  37. <result property="extJson" column="ext_json" />
  38. <result property="visitStatus" column="visit_status" />
  39. <result property="registerDate" column="register_date" />
  40. <result property="registerLinkUrl" column="register_link_url" />
  41. <result property="registerDesc" column="register_desc" />
  42. <result property="registerSubmitTime" column="register_submit_time" />
  43. <result property="isPool" column="is_pool" />
  44. <result property="registerType" column="register_type" />
  45. <result property="payMoney" column="pay_money" />
  46. <result property="buyCount" column="buy_count" />
  47. <result property="sourceCode" column="source_code" />
  48. <result property="pushTime" column="push_time" />
  49. <result property="pushCode" column="push_code" />
  50. <result property="visitTime" column="visit_time" />
  51. <result property="trafficSource" column="traffic_source" />
  52. <result property="importType" column="import_type" />
  53. <result property="thirdAccount" column="third_account" />
  54. <result property="clueId" column="clue_id" />
  55. <result property="customerLevel" column="customer_level" />
  56. <result property="isTop" column="is_top" />
  57. </resultMap>
  58. <sql id="selectCrmCustomerVo">
  59. select customer_id, customer_code, customer_name, mobile, sex, weixin, remark, user_id, create_user_id, receive_user_id, customer_user_id, address,city_ids, location, detail_address, lng, lat, create_time, update_time, status, is_receive, dept_id, is_del, customer_type, receive_time, pool_time, company_id, is_line, source, tags,ext_json,visit_status,register_date,register_link_url,register_desc,register_submit_time,is_pool,register_type,pay_money,buy_count,source_code,push_time,push_code,visit_time,traffic_source,import_type,third_account,clue_id,customer_level,is_top from crm_customer
  60. </sql>
  61. <select id="selectCrmCustomerList" parameterType="CrmCustomer" resultMap="CrmCustomerResult">
  62. <include refid="selectCrmCustomerVo"/>
  63. <where>
  64. <if test="customerCode != null and customerCode != ''"> and customer_code = #{customerCode}</if>
  65. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  66. <if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if>
  67. <if test="sex != null "> and sex = #{sex}</if>
  68. <if test="weixin != null and weixin != ''"> and weixin = #{weixin}</if>
  69. <if test="userId != null "> and user_id = #{userId}</if>
  70. <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
  71. <if test="receiveUserId != null "> and receive_user_id = #{receiveUserId}</if>
  72. <if test="customerUserId != null "> and customer_user_id = #{customerUserId}</if>
  73. <if test="address != null and address != ''"> and address = #{address}</if>
  74. <if test="location != null and location != ''"> and location = #{location}</if>
  75. <if test="detailAddress != null and detailAddress != ''"> and detail_address = #{detailAddress}</if>
  76. <if test="lng != null and lng != ''"> and lng = #{lng}</if>
  77. <if test="lat != null and lat != ''"> and lat = #{lat}</if>
  78. <if test="status != null "> and status = #{status}</if>
  79. <if test="isReceive != null "> and is_receive = #{isReceive}</if>
  80. <if test="deptId != null "> and dept_id = #{deptId}</if>
  81. <if test="isDel != null "> and is_del = #{isDel}</if>
  82. <if test="customerType != null "> and customer_type = #{customerType}</if>
  83. <if test="receiveTime != null "> and receive_time = #{receiveTime}</if>
  84. <if test="poolTime != null "> and pool_time = #{poolTime}</if>
  85. <if test="companyId != null "> and company_id = #{companyId}</if>
  86. <if test="isLine != null "> and is_line = #{isLine}</if>
  87. <if test="source != null "> and source = #{source}</if>
  88. <if test="tags != null and tags != ''"> and tags = #{tags}</if>
  89. <if test="isPool != null "> and is_pool = #{isPool}</if>
  90. <if test="trafficSource != null "> and traffic_source = #{trafficSource}</if>
  91. <if test="importType != null "> and import_type = #{importType}</if>
  92. <if test="thirdAccount != null "> and third_account = #{thirdAccount}</if>
  93. <if test="clueId != null "> and clue_id = #{clueId}</if>
  94. <if test="customerLevel != null "> and customer_level = #{customerLevel}</if>
  95. <if test="isTop != null "> and is_top = #{isTop}</if>
  96. </where>
  97. order by customer_id desc
  98. </select>
  99. <select id="selectCrmCustomerById" parameterType="Long" resultMap="CrmCustomerResult">
  100. <include refid="selectCrmCustomerVo"/>
  101. where customer_id = #{customerId}
  102. </select>
  103. <select id="selectCrmCustomerByMobile" parameterType="CrmCustomer" resultMap="CrmCustomerResult">
  104. <include refid="selectCrmCustomerVo"/>
  105. where is_line = 1 and mobile = #{mobile} and customer_id != #{customerId} and company_id = #{companyId}
  106. </select>
  107. <insert id="insertCrmCustomer" parameterType="CrmCustomer" useGeneratedKeys="true" keyProperty="customerId">
  108. insert into crm_customer
  109. <trim prefix="(" suffix=")" suffixOverrides=",">
  110. <if test="customerCode != null">customer_code,</if>
  111. <if test="customerName != null">customer_name,</if>
  112. <if test="mobile != null">mobile,</if>
  113. <if test="sex != null">sex,</if>
  114. <if test="weixin != null">weixin,</if>
  115. <if test="remark != null">remark,</if>
  116. <if test="userId != null">user_id,</if>
  117. <if test="createUserId != null">create_user_id,</if>
  118. <if test="receiveUserId != null">receive_user_id,</if>
  119. <if test="customerUserId != null">customer_user_id,</if>
  120. <if test="address != null">address,</if>
  121. <if test="cityIds != null">city_ids,</if>
  122. <if test="location != null">location,</if>
  123. <if test="detailAddress != null">detail_address,</if>
  124. <if test="lng != null">lng,</if>
  125. <if test="lat != null">lat,</if>
  126. <if test="createTime != null">create_time,</if>
  127. <if test="updateTime != null">update_time,</if>
  128. <if test="status != null">status,</if>
  129. <if test="isReceive != null">is_receive,</if>
  130. <if test="deptId != null">dept_id,</if>
  131. <if test="isDel != null">is_del,</if>
  132. <if test="customerType != null">customer_type,</if>
  133. <if test="receiveTime != null">receive_time,</if>
  134. <if test="poolTime != null">pool_time,</if>
  135. <if test="companyId != null">company_id,</if>
  136. <if test="isLine != null">is_line,</if>
  137. <if test="source != null">source,</if>
  138. <if test="tags != null">tags,</if>
  139. <if test="extJson != null">ext_json,</if>
  140. <if test="visitStatus != null">visit_status,</if>
  141. <if test="registerDate != null">register_date,</if>
  142. <if test="registerLinkUrl != null">register_link_url,</if>
  143. <if test="registerDesc != null">register_desc,</if>
  144. <if test="registerSubmitTime != null">register_submit_time,</if>
  145. <if test="isPool != null">is_pool,</if>
  146. <if test="registerType != null">register_type,</if>
  147. <if test="payMoney != null">pay_money,</if>
  148. <if test="buyCount != null">buy_count,</if>
  149. <if test="sourceCode != null">source_code,</if>
  150. <if test="pushTime != null">push_time,</if>
  151. <if test="pushCode != null">push_code,</if>
  152. <if test="visitTime != null">visit_time,</if>
  153. <if test="trafficSource != null">traffic_source,</if>
  154. <if test="importType != null">import_type,</if>
  155. <if test="thirdAccount != null">third_account,</if>
  156. <if test="clueId != null">clue_id,</if>
  157. <if test="customerLevel != null">customer_level,</if>
  158. <if test="isTop != null">is_top,</if>
  159. </trim>
  160. <trim prefix="values (" suffix=")" suffixOverrides=",">
  161. <if test="customerCode != null">#{customerCode},</if>
  162. <if test="customerName != null">#{customerName},</if>
  163. <if test="mobile != null">#{mobile},</if>
  164. <if test="sex != null">#{sex},</if>
  165. <if test="weixin != null">#{weixin},</if>
  166. <if test="remark != null">#{remark},</if>
  167. <if test="userId != null">#{userId},</if>
  168. <if test="createUserId != null">#{createUserId},</if>
  169. <if test="receiveUserId != null">#{receiveUserId},</if>
  170. <if test="customerUserId != null">#{customerUserId},</if>
  171. <if test="address != null">#{address},</if>
  172. <if test="cityIds != null">#{cityIds},</if>
  173. <if test="location != null">#{location},</if>
  174. <if test="detailAddress != null">#{detailAddress},</if>
  175. <if test="lng != null">#{lng},</if>
  176. <if test="lat != null">#{lat},</if>
  177. <if test="createTime != null">#{createTime},</if>
  178. <if test="updateTime != null">#{updateTime},</if>
  179. <if test="status != null">#{status},</if>
  180. <if test="isReceive != null">#{isReceive},</if>
  181. <if test="deptId != null">#{deptId},</if>
  182. <if test="isDel != null">#{isDel},</if>
  183. <if test="customerType != null">#{customerType},</if>
  184. <if test="receiveTime != null">#{receiveTime},</if>
  185. <if test="poolTime != null">#{poolTime},</if>
  186. <if test="companyId != null">#{companyId},</if>
  187. <if test="isLine != null">#{isLine},</if>
  188. <if test="source != null">#{source},</if>
  189. <if test="tags != null">#{tags},</if>
  190. <if test="extJson != null">#{extJson},</if>
  191. <if test="visitStatus != null">#{visitStatus},</if>
  192. <if test="registerDate != null">#{registerDate},</if>
  193. <if test="registerLinkUrl != null">#{registerLinkUrl},</if>
  194. <if test="registerDesc != null">#{registerDesc},</if>
  195. <if test="registerSubmitTime != null">#{registerSubmitTime},</if>
  196. <if test="isPool != null">#{isPool},</if>
  197. <if test="registerType != null">#{registerType},</if>
  198. <if test="payMoney != null">#{payMoney},</if>
  199. <if test="buyCount != null">#{buyCount},</if>
  200. <if test="sourceCode != null">#{sourceCode},</if>
  201. <if test="pushTime != null">#{pushTime},</if>
  202. <if test="pushCode != null">#{pushCode},</if>
  203. <if test="visitTime != null">#{visitTime},</if>
  204. <if test="trafficSource != null">#{trafficSource},</if>
  205. <if test="importType != null">#{importType},</if>
  206. <if test="thirdAccount != null">#{thirdAccount},</if>
  207. <if test="clueId != null">#{clueId},</if>
  208. <if test="customerLevel != null">#{customerLevel},</if>
  209. <if test="isTop != null">#{isTop},</if>
  210. </trim>
  211. </insert>
  212. <update id="updateCrmCustomer" parameterType="CrmCustomer">
  213. update crm_customer
  214. <trim prefix="SET" suffixOverrides=",">
  215. <if test="customerCode != null">customer_code = #{customerCode},</if>
  216. <if test="customerName != null">customer_name = #{customerName},</if>
  217. <if test="mobile != null">mobile = #{mobile},</if>
  218. <if test="sex != null">sex = #{sex},</if>
  219. <if test="weixin != null">weixin = #{weixin},</if>
  220. <if test="remark != null">remark = #{remark},</if>
  221. <if test="userId != null">user_id = #{userId},</if>
  222. <if test="createUserId != null">create_user_id = #{createUserId},</if>
  223. <if test="receiveUserId != null">receive_user_id = #{receiveUserId},</if>
  224. <if test="customerUserId != null">customer_user_id = #{customerUserId},</if>
  225. <if test="address != null">address = #{address},</if>
  226. <if test="cityIds != null">city_ids = #{cityIds},</if>
  227. <if test="location != null">location = #{location},</if>
  228. <if test="detailAddress != null">detail_address = #{detailAddress},</if>
  229. <if test="lng != null">lng = #{lng},</if>
  230. <if test="lat != null">lat = #{lat},</if>
  231. <if test="createTime != null">create_time = #{createTime},</if>
  232. <if test="updateTime != null">update_time = #{updateTime},</if>
  233. <if test="status != null">status = #{status},</if>
  234. <if test="isReceive != null">is_receive = #{isReceive},</if>
  235. <if test="deptId != null">dept_id = #{deptId},</if>
  236. <if test="isDel != null">is_del = #{isDel},</if>
  237. <if test="customerType != null">customer_type = #{customerType},</if>
  238. <if test="receiveTime != null">receive_time = #{receiveTime},</if>
  239. <if test="poolTime != null">pool_time = #{poolTime},</if>
  240. <if test="companyId != null">company_id = #{companyId},</if>
  241. <if test="isLine != null">is_line = #{isLine},</if>
  242. <if test="source != null">source = #{source},</if>
  243. <if test="tags != null">tags = #{tags},</if>
  244. <if test="extJson != null">ext_json = #{extJson},</if>
  245. <if test="visitStatus != null">visit_status = #{visitStatus},</if>
  246. <if test="registerDate != null">register_date = #{registerDate},</if>
  247. <if test="registerLinkUrl != null">register_link_url = #{registerLinkUrl},</if>
  248. <if test="registerDesc != null">register_desc = #{registerDesc},</if>
  249. <if test="registerSubmitTime != null">register_submit_time = #{registerSubmitTime},</if>
  250. <if test="isPool != null">is_pool = #{isPool},</if>
  251. <if test="registerType != null">register_type = #{registerType},</if>
  252. <if test="payMoney != null">pay_money = #{payMoney},</if>
  253. <if test="buyCount != null">buy_count = #{buyCount},</if>
  254. <if test="sourceCode != null">source_code = #{sourceCode},</if>
  255. <if test="pushTime != null">push_time = #{pushTime},</if>
  256. <if test="pushCode != null">push_code = #{pushCode},</if>
  257. <if test="visitTime != null">visit_time = #{visitTime},</if>
  258. <if test="trafficSource != null">traffic_source = #{trafficSource},</if>
  259. <if test="importType != null">import_type = #{importType},</if>
  260. <if test="thirdAccount != null">third_account = #{thirdAccount},</if>
  261. <if test="clueId != null">clue_id = #{clueId},</if>
  262. <if test="customerLevel != null">customer_level = #{customerLevel},</if>
  263. <if test="isTop != null">is_top = #{isTop},</if>
  264. </trim>
  265. where customer_id = #{customerId}
  266. </update>
  267. <delete id="deleteCrmCustomerById" parameterType="Long">
  268. delete from crm_customer where customer_id = #{customerId}
  269. </delete>
  270. <delete id="deleteCrmCustomerByIds" parameterType="String">
  271. delete from crm_customer where customer_id in
  272. <foreach item="customerId" collection="array" open="(" separator="," close=")">
  273. #{customerId}
  274. </foreach>
  275. </delete>
  276. <select id="selectCrmCustomerCounts" resultType="com.alibaba.fastjson.JSONObject">
  277. SELECT count( IF ( t.is_pool =0, 1, NULL )) AS receiveCount, t.type, count( IF ( t.is_pool = 1, 1, NULL )) AS poolCount
  278. FROM
  279. (
  280. SELECT DATE_FORMAT( cu.create_time, #{sqlDateFormat} ) AS type, cu.is_pool
  281. FROM
  282. crm_customer_user AS cu
  283. WHERE
  284. (DATE_FORMAT(cu.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
  285. AND cu.company_user_id IN
  286. <foreach item="item" collection="userIds" open="(" separator="," close=")">
  287. #{item}
  288. </foreach>
  289. ) t
  290. GROUP BY t.type
  291. </select>
  292. <select id="selectCrmMyCustomerListQuery" resultType="com.fs.crm.vo.CrmMyCustomerListQueryVO">
  293. select cu.*,c.create_time as customer_create_time,c.visit_status,c.remark,c.register_desc,c.register_submit_time,
  294. c.customer_code,c.customer_name,c.mobile,c.sex,c.weixin,c.address,c.is_receive,c.customer_type,c.source,
  295. c.tags,c.receive_time,c.customer_level
  296. from crm_customer_user cu
  297. inner join crm_customer c on c.customer_user_id=cu.customer_user_id
  298. where cu.is_pool=0 and c.is_del = 0
  299. <if test="maps.companyId != null">
  300. and cu.company_id =#{maps.companyId}
  301. </if>
  302. <if test="maps.customerLevel != null">
  303. and c.customer_level =#{maps.customerLevel}
  304. </if>
  305. <if test="maps.companyUserId != null">
  306. and cu.company_user_id =#{maps.companyUserId}
  307. </if>
  308. <if test="maps.address != null and maps.address != ''">
  309. and c.address like CONCAT('%',#{maps.address},'%')
  310. </if>
  311. <if test="maps.customerCode != null and maps.customerCode != ''">
  312. and c.customer_code like CONCAT('%',#{maps.customerCode},'%')
  313. </if>
  314. <if test="maps.customerName != null and maps.customerName != ''">
  315. and c.customer_name like CONCAT('%',#{maps.customerName},'%')
  316. </if>
  317. <if test="maps.mobile != null and maps.mobile != ''">
  318. and c.mobile like CONCAT('%',#{maps.mobile},'%')
  319. </if>
  320. <if test="maps.status != null and maps.status != ''">
  321. and c.visit_status IN
  322. <foreach collection="maps.status.split(',')" item="item" index="index" open="(" close=")" separator=",">
  323. #{item}
  324. </foreach>
  325. </if>
  326. <if test="maps.isHisOrder != null and maps.isHisOrder == 1">
  327. and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) &gt; 0
  328. </if>
  329. <if test="maps.isHisOrder != null and maps.isHisOrder == 0">
  330. and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) = 0
  331. </if>
  332. <if test="maps.customerType != null">
  333. and c.customer_type IN
  334. <foreach collection="maps.customerType.split(',')" item="item" index="index" open="(" separator="," close=")">
  335. #{item}
  336. </foreach>
  337. </if>
  338. <if test="maps.source != null and maps.source != ''">
  339. and c.source IN
  340. <foreach collection="maps.source.split(',')" item="item" index="index" open="(" separator="," close=")">
  341. #{item}
  342. </foreach>
  343. </if>
  344. <if test="maps.tags != null and maps.tags != ''">
  345. <foreach collection="maps.tags.split(',')" item="tag" open="(" separator="OR" close=")">
  346. find_in_set(#{tag},c.tags)
  347. </foreach>
  348. </if>
  349. <if test="maps.customerCreateTime != null">
  350. AND date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.customerCreateTime[0]},'%y%m%d')
  351. AND date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.customerCreateTime[1]},'%y%m%d')
  352. </if>
  353. <if test="maps.beginTime != null and maps.beginTime != ''">
  354. and date_format(c.receive_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d')
  355. </if>
  356. <if test="maps.endTime != null and maps.endTime != ''">
  357. and date_format(c.receive_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d')
  358. </if>
  359. order by cu.customer_user_id desc
  360. </select>
  361. <select id="selectCrmMyAssistListQuery" resultType="com.fs.crm.vo.CrmMyCustomerListQueryVO">
  362. select cu.*,c.create_time as customer_create_time,c.visit_status,c.remark,c.register_desc,c.register_submit_time,
  363. c.customer_code,c.customer_name,c.mobile,c.sex,c.weixin,c.address,c.is_receive,c.customer_type,c.source,
  364. c.tags,c.receive_time, c.customer_level
  365. from crm_customer_assist ca
  366. LEFT JOIN crm_customer c on c.customer_id=ca.customer_id
  367. LEFT JOIN crm_customer_user cu on c.customer_user_id=cu.customer_user_id
  368. where c.is_pool=0 and c.is_del = 0
  369. <if test="maps.companyId != null">
  370. and ca.company_id =#{maps.companyId}
  371. </if>
  372. <if test="maps.companyUserId != null">
  373. and ca.company_user_id =#{maps.companyUserId}
  374. </if>
  375. <if test="maps.customerLevel != null">
  376. and c.customer_level =#{maps.customerLevel}
  377. </if>
  378. <if test="maps.address != null and maps.address != ''">
  379. and c.address like CONCAT('%',#{maps.address},'%')
  380. </if>
  381. <if test="maps.customerCode != null and maps.customerCode != ''">
  382. and c.customer_code like CONCAT('%',#{maps.customerCode},'%')
  383. </if>
  384. <if test="maps.customerName != null and maps.customerName != ''">
  385. and c.customer_name like CONCAT('%',#{maps.customerName},'%')
  386. </if>
  387. <if test="maps.mobile != null and maps.mobile != ''">
  388. and c.mobile like CONCAT('%',#{maps.mobile},'%')
  389. </if>
  390. <if test="maps.status != null and maps.status != ''">
  391. and c.visit_status IN
  392. <foreach collection="maps.status.split(',')" item="item" index="index" open="(" close=")" separator=",">
  393. #{item}
  394. </foreach>
  395. </if>
  396. <if test="maps.isHisOrder != null and maps.isHisOrder == 1">
  397. and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) &gt; 0
  398. </if>
  399. <if test="maps.isHisOrder != null and maps.isHisOrder == 0">
  400. and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) = 0
  401. </if>
  402. <if test="maps.customerType != null">
  403. and c.customer_type IN
  404. <foreach collection="maps.customerType.split(',')" item="item" index="index" open="(" separator="," close=")">
  405. #{item}
  406. </foreach>
  407. </if>
  408. <if test="maps.source != null and maps.source != ''">
  409. and c.source IN
  410. <foreach collection="maps.source.split(',')" item="item" index="index" open="(" separator="," close=")">
  411. #{item}
  412. </foreach>
  413. </if>
  414. <if test="maps.tags != null and maps.tags != ''">
  415. <foreach collection="maps.tags.split(',')" item="tag" open="(" separator="OR" close=")">
  416. find_in_set(#{tag},c.tags)
  417. </foreach>
  418. </if>
  419. <if test="maps.customerCreateTime != null">
  420. AND date_format(c.create_time,'%y%m%d') &gt;= date_format(#{maps.customerCreateTime[0]},'%y%m%d')
  421. AND date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.customerCreateTime[1]},'%y%m%d')
  422. </if>
  423. <if test="maps.beginTime != null and maps.beginTime != ''">
  424. and date_format(c.receive_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d')
  425. </if>
  426. <if test="maps.endTime != null and maps.endTime != ''">
  427. and date_format(c.receive_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d')
  428. </if>
  429. order by cu.customer_user_id desc
  430. </select>
  431. <select id="selectCustomerIdByCompanyUserId" resultType="java.lang.Long">
  432. SELECT customer_id FROM crm_customer_user where company_user_id = #{companyUserId}
  433. </select>
  434. </mapper>