QwSopMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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.sop.mapper.QwSopMapper">
  6. <resultMap type="com.fs.sop.domain.QwSop" id="QwSopResult">
  7. <result property="id" column="id" />
  8. <result property="name" column="name" />
  9. <result property="status" column="status" />
  10. <result property="type" column="type" />
  11. <result property="qwUserIds" column="qw_user_ids" />
  12. <result property="createBy" column="create_by" />
  13. <result property="createTime" column="create_time" />
  14. <result property="companyId" column="company_id" />
  15. <result property="sendType" column="send_type" />
  16. <result property="tags" column="tags" />
  17. <result property="excludeTags" column="exclude_tags" />
  18. <result property="startTime" column="start_time" />
  19. <result property="filterMode" column="filter_mode" />
  20. <result property="filterType" column="filter_type" />
  21. <result property="tempId" column="temp_id" />
  22. <result property="corpId" column="corp_id" />
  23. <result property="expiryTime" column="expiry_time" />
  24. <result property="isAutoSop" column="is_auto_sop" />
  25. <result property="autoSopTime" column="auto_sop_time" />
  26. <result property="minConversionDay" column="min_conversion_day" />
  27. <result property="maxConversionDay" column="max_conversion_day" />
  28. <result property="minSend" column="min_send" />
  29. <result property="maxSend" column="max_send" />
  30. <result property="stopTime" column="stop_time" />
  31. <result property="isRating" column="is_rating" />
  32. <result property="courseDay" column="course_day" />
  33. <result property="isFixed" column="is_fixed" />
  34. <result property="chatId" column="chat_id" />
  35. <result property="openCommentStatus" column="open_comment_status" />
  36. <result property="isSampSend" column="is_samp_send" />
  37. <result property="isLiveMgs" column="is_live_mgs" />
  38. <result property="liveTempId" column="live_temp_id" />
  39. <result property="liveTempSendTime" column="live_temp_send_time" />
  40. <result property="autoGroup" column="auto_group" />
  41. <result property="autoGroupLevel" column="auto_group_level" />
  42. <result property="groupName" column="group_name" />
  43. <result property="deadLineTime" column="dead_line_time" />
  44. </resultMap>
  45. <sql id="selectQwSopVo">
  46. select *
  47. from qw_sop
  48. </sql>
  49. <select id="selectQwSopAutoByTagsByForeach" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  50. SELECT
  51. qs.*,
  52. qst.name AS temp_name,
  53. qst.setting AS temp_setting,
  54. qst.status AS temp_status,
  55. qst.gap AS temp_gap,
  56. qst.sort AS temp_sort,
  57. qst.create_time AS temp_create_time,
  58. qst.create_by AS temp_create_by,
  59. qst.corp_id AS temp_company_id
  60. FROM
  61. qw_sop qs
  62. LEFT JOIN
  63. qw_sop_temp qst ON qs.temp_id = qst.id AND qst.status = '1'
  64. WHERE
  65. qs.corp_id = #{map.corpId}
  66. AND qs.status IN (2, 3, 4)
  67. AND qs.send_type in (2,11)
  68. AND qs.is_auto_sop = 1
  69. AND FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
  70. AND (
  71. <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' or '>
  72. find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')))
  73. </foreach>
  74. )
  75. </select>
  76. <select id="selectQwSopAutoByTagsByForeachNotAuto" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  77. SELECT
  78. qs.*,
  79. qst.name AS temp_name,
  80. qst.setting AS temp_setting,
  81. qst.status AS temp_status,
  82. qst.gap AS temp_gap,
  83. qst.sort AS temp_sort,
  84. qst.create_time AS temp_create_time,
  85. qst.create_by AS temp_create_by,
  86. qst.corp_id AS temp_company_id
  87. FROM
  88. qw_sop qs
  89. LEFT JOIN
  90. qw_sop_temp qst ON qs.temp_id = qst.id AND qst.status = '1'
  91. WHERE
  92. qs.corp_id = #{map.corpId}
  93. AND qs.status IN (2, 3, 4)
  94. AND qs.send_type IN (2,11)
  95. AND FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
  96. AND (
  97. <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' or '>
  98. find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')) )
  99. </foreach>
  100. )
  101. </select>
  102. <select id="selectQwSopAutoByTagsByForeachRemoveNotAuto" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  103. SELECT
  104. qs.*,
  105. qst.name AS temp_name,
  106. qst.setting AS temp_setting,
  107. qst.status AS temp_status,
  108. qst.gap AS temp_gap,
  109. qst.sort AS temp_sort,
  110. qst.create_time AS temp_create_time,
  111. qst.create_by AS temp_create_by,
  112. qst.corp_id AS temp_company_id
  113. FROM
  114. qw_sop qs
  115. LEFT JOIN
  116. qw_sop_temp qst ON qs.temp_id = qst.id AND qst.status = '1'
  117. WHERE
  118. qs.corp_id = #{map.corpId}
  119. AND qs.status IN (2, 3, 4)
  120. AND qs.send_type IN (2,11)
  121. AND FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
  122. AND (
  123. <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' and '>
  124. NOT find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')) )
  125. </foreach>
  126. )
  127. </select>
  128. <select id="selectQwAiSopAutoByTagsByForeach" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  129. SELECT
  130. qs.*,
  131. qs.dead_line_time AS deadLineTime,
  132. qst.name AS temp_name,
  133. qst.setting AS temp_setting,
  134. qst.status AS temp_status,
  135. qst.gap AS temp_gap,
  136. qst.sort AS temp_sort,
  137. qst.create_time AS temp_create_time,
  138. qst.create_by AS temp_create_by,
  139. qst.corp_id AS temp_company_id
  140. FROM
  141. qw_sop qs
  142. LEFT JOIN
  143. qw_sop_temp qst ON qs.temp_id = qst.id AND qst.status = '1'
  144. WHERE
  145. qs.corp_id = #{map.corpId}
  146. AND qs.status IN (2, 3, 4)
  147. AND qs.send_type = 4
  148. AND FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
  149. AND (
  150. <foreach collection='map.tagsIdsSelectList' item='item' index='index' separator=' or '>
  151. find_in_set( #{item}, TRIM(REGEXP_REPLACE(qs.tags, '[\"\\\\[\\\\]]', '')) )
  152. </foreach>
  153. )
  154. </select>
  155. <select id="selectQwSopByQwUserId" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  156. SELECT
  157. qs.*
  158. FROM
  159. qw_sop qs
  160. LEFT JOIN
  161. qw_sop_temp qst ON qs.temp_id = qst.id AND qst.status = '1'
  162. WHERE
  163. qs.corp_id = #{map.corpId}
  164. AND qs.status IN (2, 3, 4)
  165. AND qs.send_type IN (2,11)
  166. AND FIND_IN_SET(#{map.qwUserId}, COALESCE(qs.qw_user_ids, '')) > 0
  167. </select>
  168. <select id="checkSopRuleTime" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  169. <![CDATA[
  170. SELECT
  171. qs.*,
  172. qst.name AS temp_name,
  173. qst.setting AS temp_setting,
  174. qst.status AS temp_status,
  175. qst.gap AS temp_gap,
  176. qst.sort AS temp_sort,
  177. qst.create_time AS temp_create_time,
  178. qst.create_by AS temp_create_by,
  179. qst.corp_id AS temp_company_id
  180. FROM
  181. qw_sop qs
  182. LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
  183. WHERE
  184. qs.status = 1
  185. AND qs.start_time <= NOW()
  186. ]]>
  187. </select>
  188. <select id="selectQwSopByClickHouseId" parameterType="String" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  189. <![CDATA[
  190. SELECT
  191. qs.*,
  192. qst.name AS temp_name,
  193. qst.setting AS temp_setting,
  194. qst.status AS temp_status,
  195. qst.gap AS temp_gap,
  196. qst.sort AS temp_sort,
  197. qst.create_time AS temp_create_time,
  198. qst.create_by AS temp_create_by,
  199. qst.corp_id AS temp_company_id
  200. FROM
  201. qw_sop qs
  202. LEFT JOIN
  203. qw_sop_temp qst
  204. ON
  205. qs.temp_id = qst.id
  206. WHERE
  207. qs.id = #{id}
  208. ]]>
  209. </select>
  210. <select id="selectWxSopByClickHouseId" parameterType="String" resultType="com.fs.qw.vo.WxSopRuleTimeVO">
  211. <![CDATA[
  212. SELECT
  213. ws.*,
  214. qst.name AS temp_name,
  215. qst.setting AS temp_setting,
  216. qst.status AS temp_status,
  217. qst.gap AS temp_gap,
  218. qst.sort AS temp_sort,
  219. qst.create_time AS temp_create_time,
  220. qst.create_by AS temp_create_by,
  221. qst.corp_id
  222. FROM
  223. wx_sop ws
  224. LEFT JOIN
  225. qw_sop_temp qst
  226. ON
  227. ws.temp_id = qst.id
  228. WHERE
  229. ws.id = #{id}
  230. ]]>
  231. </select>
  232. <select id="selectQwSopList" parameterType="QwSop" resultMap="QwSopResult">
  233. <include refid="selectQwSopVo"/>
  234. <where>
  235. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  236. <if test="status != null "> and status = #{status}</if>
  237. <if test="type != null "> and type = #{type}</if>
  238. <if test="id != null "> and id = #{id}</if>
  239. <if test="companyId != null "> and company_id = #{companyId}</if>
  240. <if test="qwUserIds != null and qwUserIds != ''"> and FIND_IN_SET(#{qwUserIds}, qw_user_ids) > 0</if>
  241. <if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
  242. <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
  243. <if test="createTime != null "> and DATE(create_time) = #{createTime}</if>
  244. <if test="sendType != null "> and send_type = #{sendType}</if>
  245. <if test="expiryTime != null "> and expiry_time = #{expiryTime}</if>
  246. <if test="isAutoSop != null "> and is_auto_sop = #{isAutoSop}</if>
  247. <if test="autoSopTime != null "> and auto_sop_time = #{autoSopTime}</if>
  248. <if test="minSend != null "> and min_send = #{minSend}</if>
  249. <if test="maxSend != null "> and max_send = #{maxSend}</if>
  250. <if test="stopTime != null "> and stop_time = #{stopTime}</if>
  251. <if test="qwUserIdList != null and !qwUserIdList.isEmpty() ">
  252. and (
  253. <foreach collection='qwUserIdList' item='item' index='index' separator=' or '>
  254. find_in_set( #{item} , REGEXP_REPLACE(qw_user_ids, '[\"\\\\[\\\\]]', '' ) )
  255. </foreach>
  256. )
  257. </if>
  258. and status != 6
  259. </where>
  260. order by create_time desc
  261. </select>
  262. <select id="selectChatQwSopList" parameterType="QwSop" resultMap="QwSopResult">
  263. <include refid="selectQwSopVo"/>
  264. where send_type = 4
  265. and status != 6
  266. order by create_time desc
  267. </select>
  268. <select id="selectQwSopByIsRating" parameterType="QwSop" resultMap="QwSopResult">
  269. <include refid="selectQwSopVo"/>
  270. where is_rating = 1
  271. and send_type in(2,3,11)
  272. order by create_time desc
  273. </select>
  274. <select id="selectQwSopById" parameterType="String" resultType="com.fs.sop.domain.QwSop">
  275. <include refid="selectQwSopVo"/>
  276. where id = #{id}
  277. </select>
  278. <insert id="insertQwSop" parameterType="com.fs.sop.domain.QwSop" useGeneratedKeys="false" keyProperty="id">
  279. insert into qw_sop
  280. <trim prefix="(" suffix=")" suffixOverrides=",">
  281. <if test="data.name != null">name,</if>
  282. <if test="data.status != null">status,</if>
  283. <if test="data.type != null">type,</if>
  284. <if test="data.qwUserIds != null">qw_user_ids,</if>
  285. <if test="data.createBy != null">create_by,</if>
  286. <if test="data.createTime != null">create_time,</if>
  287. <if test="data.companyId != null">company_id,</if>
  288. <if test="data.sendType != null">send_type,</if>
  289. <if test="data.tags != null">tags,</if>
  290. <if test="data.excludeTags != null">exclude_tags,</if>
  291. <if test="data.startTime != null">start_time,</if>
  292. <if test="data.filterType != null">filter_type,</if>
  293. <if test="data.tempId != null">temp_id,</if>
  294. <if test="data.corpId != null">corp_id,</if>
  295. <if test="data.expiryTime != null">expiry_time,</if>
  296. <if test="data.isAutoSop != null">is_auto_sop,</if>
  297. <if test="data.autoSopTime != null">auto_sop_time,</if>
  298. <if test="data.minConversionDay != null">min_conversion_day,</if>
  299. <if test="data.maxConversionDay != null">max_conversion_day,</if>
  300. <if test="data.minSend != null">min_send,</if>
  301. <if test="data.maxSend != null">max_send,</if>
  302. <if test="data.isRating != null">is_rating,</if>
  303. <if test="data.courseDay != null">course_day,</if>
  304. <if test="data.openCommentStatus != null">open_comment_status,</if>
  305. <if test="data.isLiveMgs != null">is_live_mgs,</if>
  306. <if test="data.liveTempId != null">live_temp_id,</if>
  307. <if test="data.liveTempSendTime != null">live_temp_send_time,</if>
  308. <if test="data.autoGroup != null">auto_group,</if>
  309. <if test="data.autoGroupLevel != null">auto_group_level,</if>
  310. <if test="data.groupName != null">group_name,</if>
  311. <if test="data.isFixed != null">is_fixed,</if>
  312. <if test="data.deadLineTime != null">dead_line_time,</if>
  313. </trim>
  314. <trim prefix="values (" suffix=")" suffixOverrides=",">
  315. <if test="data.name != null">#{data.name},</if>
  316. <if test="data.status != null">#{data.status},</if>
  317. <if test="data.type != null">#{data.type},</if>
  318. <if test="data.qwUserIds != null">#{data.qwUserIds},</if>
  319. <if test="data.createBy != null">#{data.createBy},</if>
  320. <if test="data.createTime != null">#{data.createTime},</if>
  321. <if test="data.companyId != null">#{data.companyId},</if>
  322. <if test="data.sendType != null">#{data.sendType},</if>
  323. <if test="data.tags != null">#{data.tags},</if>
  324. <if test="data.excludeTags != null">#{data.excludeTags},</if>
  325. <if test="data.startTime != null">#{data.startTime},</if>
  326. <if test="data.filterType != null">#{data.filterType},</if>
  327. <if test="data.tempId != null">#{data.tempId},</if>
  328. <if test="data.corpId != null">#{data.corpId},</if>
  329. <if test="data.expiryTime != null">#{data.expiryTime},</if>
  330. <if test="data.isAutoSop != null">#{data.isAutoSop},</if>
  331. <if test="data.autoSopTime != null">#{data.autoSopTime},</if>
  332. <if test="data.minConversionDay != null">#{data.minConversionDay},</if>
  333. <if test="data.maxConversionDay != null">#{data.maxConversionDay},</if>
  334. <if test="data.minSend != null">#{data.minSend},</if>
  335. <if test="data.maxSend != null">#{data.maxSend},</if>
  336. <if test="data.isRating != null">#{data.isRating},</if>
  337. <if test="data.courseDay != null">#{data.courseDay},</if>
  338. <if test="data.openCommentStatus != null">#{data.openCommentStatus},</if>
  339. <if test="data.isLiveMgs != null">#{data.isLiveMgs},</if>
  340. <if test="data.liveTempId != null">#{data.liveTempId},</if>
  341. <if test="data.liveTempSendTime != null">#{data.liveTempSendTime},</if>
  342. <if test="data.autoGroup != null">#{data.autoGroup},</if>
  343. <if test="data.autoGroupLevel != null">#{data.autoGroupLevel},</if>
  344. <if test="data.groupName != null">#{data.groupName},</if>
  345. <if test="data.isFixed != null">#{data.isFixed},</if>
  346. <if test="data.deadLineTime != null">#{data.deadLineTime},</if>
  347. </trim>
  348. </insert>
  349. <update id="updateAutoSopTime" useGeneratedKeys="false" keyProperty="id" >
  350. UPDATE qw_sop
  351. SET
  352. is_auto_sop = #{map.isAutoSop}
  353. <if test="map.autoSopTime != null and map.autoSopTime != ''">
  354. ,auto_sop_time = #{map.autoSopTime}
  355. </if>
  356. WHERE id = #{map.id}
  357. </update>
  358. <update id="updateSopStatus" useGeneratedKeys="false" keyProperty="id" >
  359. UPDATE qw_sop
  360. SET status = #{map.status},stop_time = NOW()
  361. WHERE id = #{map.id}
  362. </update>
  363. <select id="selectStatusQwSopById" resultType="QwSop">
  364. select * from qw_sop where id in
  365. <foreach item="id" collection="ids" open="(" separator="," close=")">
  366. #{id}
  367. </foreach>
  368. </select>
  369. <select id="executeSopByIds" resultType="com.fs.qw.vo.QwSopRuleTimeVO">
  370. SELECT qs.*,
  371. qst.name AS temp_name,
  372. qst.setting AS temp_setting,
  373. qst.status AS temp_status,
  374. qst.gap AS temp_gap,
  375. qst.sort AS temp_sort,
  376. qst.create_time AS temp_create_time,
  377. qst.create_by AS temp_create_by,
  378. qst.corp_id AS temp_company_id
  379. FROM qw_sop qs
  380. LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
  381. WHERE qs.id IN
  382. <foreach item="id" collection="ids" open="(" separator="," close=")">
  383. #{id}
  384. </foreach>
  385. </select>
  386. <select id="executeSopWxByIds" resultType="com.fs.qw.vo.WxSopRuleTimeVO">
  387. SELECT qs.*,
  388. qst.name AS temp_name,
  389. qst.setting AS temp_setting,
  390. qst.status AS temp_status,
  391. qst.gap AS temp_gap,
  392. qst.sort AS temp_sort,
  393. qst.create_time AS temp_create_time,
  394. qst.create_by AS temp_create_by,
  395. qst.corp_id AS temp_company_id
  396. FROM qw_sop qs
  397. LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
  398. WHERE qs.id IN
  399. <foreach item="id" collection="ids" open="(" separator="," close=")">
  400. #{id}
  401. </foreach>
  402. </select>
  403. <select id="selectAiChatQwSopList" resultType="com.fs.sop.domain.QwSop">
  404. <include refid="selectQwSopVo"/>
  405. <where>
  406. send_type = 4
  407. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  408. <if test="status != null "> and status = #{status}</if>
  409. <if test="type != null "> and type = #{type}</if>
  410. <if test="companyId != null "> and company_id = #{companyId}</if>
  411. <if test="qwUserIds != null and qwUserIds != ''"> and qw_user_ids = #{qwUserIds}</if>
  412. <if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
  413. <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
  414. <if test="createTime != null "> and DATE(create_time) = #{createTime}</if>
  415. <if test="expiryTime != null "> and expiry_time = #{expiryTime}</if>
  416. <if test="isAutoSop != null "> and is_auto_sop = #{isAutoSop}</if>
  417. <if test="autoSopTime != null "> and auto_sop_time = #{autoSopTime}</if>
  418. <if test="minSend != null "> and min_send = #{minSend}</if>
  419. <if test="maxSend != null "> and max_send = #{maxSend}</if>
  420. <if test="stopTime != null "> and stop_time = #{stopTime}</if>
  421. <if test="isLiveMgs != null "> and is_live_mgs = #{isLiveMgs}</if>
  422. <if test="liveTempId != null "> and live_temp_id = #{liveTempId}</if>
  423. <if test="liveTempSendTime != null "> and live_temp_send_time = #{liveTempSendTime}</if>
  424. <if test="groupName != null "> and group_name = #{groupName}</if>
  425. <!-- 加入固定条件 -->
  426. and status != 6
  427. </where>
  428. order by create_time desc
  429. </select>
  430. <select id="selectByTemplateId" resultType="com.fs.sop.domain.QwSop">
  431. select * from qw_sop where temp_id = #{tempId}
  432. </select>
  433. <select id="selectWxSop" resultType="com.fs.sop.domain.QwSop">
  434. select a.* from qw_sop a
  435. where a.send_type != 4 and a.status in (2,3) and a.type = 1
  436. </select>
  437. <select id="executeSopChatByIds" resultType="com.fs.qw.vo.ChatSopRuleTimeVO">
  438. SELECT qs.*,
  439. qst.name AS temp_name,
  440. qst.setting AS temp_setting,
  441. qst.status AS temp_status,
  442. qst.gap AS temp_gap,
  443. qst.sort AS temp_sort,
  444. qst.create_time AS temp_create_time,
  445. qst.create_by AS temp_create_by,
  446. qst.corp_id AS temp_company_id
  447. FROM qw_sop qs
  448. LEFT JOIN qw_sop_temp qst ON qs.temp_id = qst.id
  449. WHERE qs.id IN
  450. <foreach item="id" collection="ids" open="(" separator="," close=")">
  451. #{id}
  452. </foreach>
  453. </select>
  454. <select id="selectQwSopAllList" resultType="com.fs.sop.domain.QwSop">
  455. SELECT DISTINCT qw_sop.id,qw_sop.name
  456. FROM sop_user_logs log
  457. RIGHT JOIN qw_sop ON log.sop_id = qw_sop.id
  458. <where>
  459. <![CDATA[
  460. log.start_time <= CURDATE()
  461. ]]>
  462. AND log.status = 1
  463. AND qw_sop.status in(2,3,6)
  464. <if test="startDate!=null and endDate!=null">
  465. <![CDATA[
  466. AND log.start_time >= #{startDate}
  467. AND log.start_time <= #{endDate}
  468. ]]>
  469. </if>
  470. <if test="companyId != null">
  471. AND qw_sop.company_id = ${companyId}
  472. </if>
  473. </where>
  474. ORDER BY qw_sop.create_time DESC
  475. </select>
  476. <select id="selectQwSopByTempId" resultType="com.fs.sop.domain.QwSop">
  477. <include refid="selectQwSopVo"/>
  478. where temp_id = #{tempId}
  479. </select>
  480. <update id="updateQwSop" parameterType="QwSop" useGeneratedKeys="false" keyProperty="id" >
  481. UPDATE qw_sop
  482. <trim prefix="SET" suffixOverrides=",">
  483. <if test="data.name != null">name = #{data.name},</if>
  484. <if test="data.status != null">status = #{data.status},</if>
  485. <if test="data.type != null">type = #{data.type},</if>
  486. <if test="data.qwUserIds != null">qw_user_ids = #{data.qwUserIds},</if>
  487. <if test="data.createBy != null">create_by = #{data.createBy},</if>
  488. <if test="data.createTime != null">create_time = #{data.createTime},</if>
  489. <if test="data.companyId != null">company_id = #{data.companyId},</if>
  490. <if test="data.sendType != null">send_type = #{data.sendType},</if>
  491. <if test="data.tags != null">tags = #{data.tags},</if>
  492. <if test="data.excludeTags != null">exclude_tags = #{data.excludeTags},</if>
  493. <if test="data.startTime != null">start_time = #{data.startTime},</if>
  494. <if test="data.filterType != null">filter_type = #{data.filterType},</if>
  495. <if test="data.tempId != null">temp_id = #{data.tempId},</if>
  496. <if test="data.corpId != null">corp_id = #{data.corpId},</if>
  497. <if test="data.expiryTime != null">expiry_time = #{data.expiryTime},</if>
  498. <if test="data.isAutoSop != null">is_auto_sop = #{data.isAutoSop},</if>
  499. <if test="data.autoSopTime != null">auto_sop_time = #{data.autoSopTime},</if>
  500. <if test="data.minConversionDay != null">min_conversion_day = #{data.minConversionDay},</if>
  501. <if test="data.maxConversionDay != null">max_conversion_day = #{data.maxConversionDay},</if>
  502. <if test="data.minSend != null">min_send = #{data.minSend},</if>
  503. <if test="data.maxSend != null">max_send = #{data.maxSend},</if>
  504. <if test="data.voice != null">voice = #{data.voice},</if>
  505. <if test="data.isRating != null">is_rating = #{data.isRating},</if>
  506. <if test="data.courseDay != null">course_day = #{data.courseDay},</if>
  507. <if test="data.openCommentStatus != null">open_comment_status = #{data.openCommentStatus},</if>
  508. <if test="data.chatId != null">chat_id = #{data.chatId},</if>
  509. <if test="data.isSampSend != null">is_samp_send = #{data.isSampSend},</if>
  510. <if test="data.isLiveMgs != null">is_live_mgs = #{data.isLiveMgs},</if>
  511. <if test="data.liveTempId != null">live_temp_id = #{data.liveTempId},</if>
  512. <if test="data.liveTempSendTime != null">live_temp_send_time = #{data.liveTempSendTime},</if>
  513. <if test="data.autoGroup != null">auto_group = #{data.autoGroup},</if>
  514. <if test="data.autoGroupLevel != null">auto_group_level = #{data.autoGroupLevel},</if>
  515. <if test="data.groupName != null">group_name = #{data.groupName},</if>
  516. <if test="data.isFixed != null">is_fixed = #{data.isFixed},</if>
  517. <if test="data.deadLineTime != null">dead_line_time = #{data.deadLineTime},</if>
  518. </trim>
  519. where id = #{data.id}
  520. </update>
  521. <delete id="deleteQwSopById" parameterType="String">
  522. DELETE FROM qw_sop
  523. where id = #{id}
  524. </delete>
  525. <delete id="deleteQwSopByIds" parameterType="String">
  526. DELETE FROM qw_sop
  527. where id in
  528. <foreach item="id" collection="array" open="(" separator="," close=")">
  529. #{id}
  530. </foreach>
  531. </delete>
  532. <update id="deleteQwSopByIdsUpdate" useGeneratedKeys="false" keyProperty="id">
  533. UPDATE qw_sop
  534. SET status = 6
  535. WHERE id IN
  536. <foreach item="id" collection="ids" open="(" separator="," close=")">
  537. #{id}
  538. </foreach>
  539. </update>
  540. <update id="updateStatusQwSopById" useGeneratedKeys="false" keyProperty="id" >
  541. UPDATE qw_sop
  542. SET status = 4
  543. WHERE id IN
  544. <foreach item="id" collection="ids" open="(" separator="," close=")">
  545. #{id}
  546. </foreach>
  547. </update>
  548. <update id="updateMinSendStatus">
  549. UPDATE qw_sop
  550. SET min_send = 1
  551. WHERE id = #{id}
  552. </update>
  553. <update id="updateMaxSendStatus">
  554. UPDATE qw_sop
  555. SET max_send = 1
  556. WHERE id = #{id}
  557. </update>
  558. <update id="updateStatusQwSopById2" useGeneratedKeys="false" keyProperty="id" >
  559. UPDATE qw_sop
  560. SET status = 3
  561. WHERE id IN
  562. <foreach item="id" collection="ids" open="(" separator="," close=")">
  563. #{id}
  564. </foreach>
  565. </update>
  566. <update id="batchUpdateSopChatIdById">
  567. <foreach collection="sopList" item="item" separator=";">
  568. UPDATE qw_sop
  569. SET chat_id = #{item.chatId}
  570. WHERE id = #{item.id}
  571. </foreach>
  572. </update>
  573. <select id="getQwSopInfoById" resultType="com.fs.sop.domain.QwSop">
  574. SELECT id,filter_mode,chat_id FROM qw_sop where id IN <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">#{item}</foreach>
  575. </select>
  576. <select id="selectAllQwSopInfo" parameterType="QwSop" resultMap="QwSopResult">
  577. <include refid="selectQwSopVo"/>
  578. <where>
  579. status != 6
  580. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  581. <if test="status != null "> and status = #{status}</if>
  582. <if test="type != null "> and type = #{type}</if>
  583. <if test="id != null "> and id = #{id}</if>
  584. <if test="companyId != null "> and company_id = #{companyId}</if>
  585. <if test="qwUserIds != null and qwUserIds != ''"> and FIND_IN_SET(#{qwUserIds}, qw_user_ids) > 0</if>
  586. <if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
  587. <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
  588. <if test="createTime != null "> and DATE(create_time) = #{createTime}</if>
  589. <if test="sendType != null "> and send_type = #{sendType}</if>
  590. <if test="expiryTime != null "> and expiry_time = #{expiryTime}</if>
  591. <if test="isAutoSop != null "> and is_auto_sop = #{isAutoSop}</if>
  592. <if test="autoSopTime != null "> and auto_sop_time = #{autoSopTime}</if>
  593. <if test="minSend != null "> and min_send = #{minSend}</if>
  594. <if test="maxSend != null "> and max_send = #{maxSend}</if>
  595. <if test="stopTime != null "> and stop_time = #{stopTime}</if>
  596. </where>
  597. order by create_time desc
  598. </select>
  599. <select id="selectGroup" resultMap="QwSopResult">
  600. select * from qw_sop where auto_group = 1
  601. </select>
  602. <select id="fetchScheduleList" parameterType="String" resultMap="QwSopResult">
  603. <include refid="selectQwSopVo"/>
  604. <where>
  605. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  606. </where>
  607. </select>
  608. <update id="updateSopGroupIds">
  609. update qw_sop set chat_id = #{chatId},pull_time = now() where id = #{id}
  610. </update>
  611. </mapper>