HelpActivityMapper.xml 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.huiju.estateagents.mapper.HelpActivityMapper">
  4. <select id="helpActivityListPage" resultType="com.huiju.estateagents.entity.HelpActivity">
  5. SELECT
  6. COUNT(hir.verification) as succeedCount,
  7. ha.*
  8. FROM
  9. ta_help_activity ha
  10. LEFT JOIN ta_help_initiate_record hir ON ha.help_activity_id = hir.help_activity_id
  11. AND (hir.verification is NULL or hir.verification != '')
  12. <where>
  13. <if test="cityId != null and cityId != ''">
  14. and ha.city_id = #{cityId}
  15. </if>
  16. <if test="buildingId != null and buildingId != ''">
  17. and ha.building_id = #{buildingId}
  18. </if>
  19. <if test="title != null and title != ''">
  20. and ha.title like CONCAT('%',#{title}, '%')
  21. </if>
  22. <if test="startDate != null and startDate != ''and startDate!='Invalid date'">
  23. and date_format(ha.start_date,'%Y-%m-%d') = date_format( #{startDate}, '%Y-%m-%d' )
  24. </if>
  25. <if test="endDate != null and endDate != ''and endDate!='Invalid date'">
  26. and date_format(ha.end_date,'%Y-%m-%d') = date_format( #{endDate}, '%Y-%m-%d' )
  27. </if>
  28. <if test="activityStatus != null and activityStatus != null">
  29. and ha.activity_status = #{activityStatus}
  30. </if>
  31. and ha.org_id=#{orgId}
  32. </where>
  33. GROUP BY ha.help_activity_id
  34. order by ha.activity_status = 0 desc,
  35. ha.activity_status = 1 desc,
  36. ha.activity_status = 2 desc,
  37. ha.start_date asc
  38. </select>
  39. <update id="updateUnStartHelpActivity">
  40. update ta_help_activity t
  41. set activity_status = 0
  42. where
  43. t.activity_status != '2' and NOW() BETWEEN t.start_date and t.end_date
  44. </update>
  45. <update id="updateProcessingHelpActivity">
  46. update ta_help_activity t
  47. set activity_status = 2
  48. where
  49. t.activity_status != '2'
  50. and NOW() > t.end_date
  51. </update>
  52. <select id="selectWxhelpActivityAndGroup" resultType="com.huiju.estateagents.entity.HelpActivity">
  53. (
  54. SELECT
  55. a.city_id as cityId,
  56. a.help_activity_id as activityId,
  57. a.img as img,
  58. 1 AS type
  59. FROM
  60. ta_help_activity a
  61. WHERE
  62. a.org_id =#{orgId}
  63. and a.is_main = 1
  64. and a.city_id = #{cityID}
  65. <if test="buildingId != null and buildingId != ''">
  66. and a.building_id = #{buildingId}
  67. </if>
  68. )
  69. UNION ALL
  70. (
  71. SELECT
  72. s.city_id as cityId,
  73. s.group_activity_id as activityId,
  74. s.main_img as img,
  75. 2 AS type
  76. FROM
  77. ta_share_activity s
  78. WHERE
  79. s.org_id =#{orgId}
  80. and s.sort = 1
  81. and s.city_id = #{cityID}
  82. <if test="buildingId != null and buildingId != ''">
  83. and s.building_id = #{buildingId}
  84. </if>
  85. )
  86. </select>
  87. <select id="helpActivityListEffectivePage" resultType="com.huiju.estateagents.entity.HelpActivity">
  88. SELECT
  89. ha.*
  90. FROM
  91. ta_help_activity ha
  92. <where>
  93. <if test="cityId != null and cityId != ''">
  94. and ha.city_id = #{cityId}
  95. </if>
  96. and ha.org_id=#{orgId}
  97. and ha.activity_status in (0, 1)
  98. </where>
  99. GROUP BY ha.help_activity_id
  100. order by ha.activity_status = 0 desc,
  101. ha.activity_status = 1 desc,
  102. ha.activity_status = 2 desc,
  103. ha.start_date asc
  104. </select>
  105. </mapper>