QwSopMapper.xml 27 KB

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