HelpActivityMapper.xml 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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="updateActivityToUnStart">
  40. update ta_help_activity
  41. set activity_status = 1
  42. where
  43. NOW() &lt;= start_date and activity_status != 2
  44. </update>
  45. <update id="updateUnStartHelpActivity">
  46. update ta_help_activity t
  47. set activity_status = 0
  48. where
  49. t.activity_status != '2' and NOW() BETWEEN t.start_date and t.end_date
  50. </update>
  51. <update id="updateProcessingHelpActivity">
  52. update ta_help_activity t
  53. set activity_status = 2
  54. where
  55. t.activity_status != '2' and NOW() > t.end_date
  56. </update>
  57. <select id="selectWxhelpActivityAndGroup" resultType="com.huiju.estateagents.entity.HelpActivity">
  58. (
  59. SELECT
  60. a.city_id as cityId,
  61. a.help_activity_id as activityId,
  62. a.img as img,
  63. 1 AS type
  64. FROM
  65. ta_help_activity a
  66. WHERE
  67. a.org_id =#{orgId}
  68. <if test="buildingId == null ">
  69. and a.is_main = 1
  70. </if>
  71. <if test="cityID != null and cityID != ''">
  72. and a.city_id = #{cityID}
  73. </if>
  74. <if test="buildingId != null and buildingId != ''">
  75. and a.building_id = #{buildingId}
  76. </if>
  77. )
  78. UNION ALL
  79. (
  80. SELECT
  81. s.city_id as cityId,
  82. s.group_activity_id as activityId,
  83. s.main_img as img,
  84. 2 AS type
  85. FROM
  86. ta_share_activity s
  87. WHERE
  88. s.org_id =#{orgId}
  89. <if test="buildingId == null ">
  90. and s.sort = 1
  91. </if>
  92. <if test="cityID != null and cityID != ''">
  93. and s.city_id = #{cityID}
  94. </if>
  95. <if test="buildingId != null and buildingId != ''">
  96. and s.building_id = #{buildingId}
  97. </if>
  98. )
  99. </select>
  100. <select id="helpActivityListEffectivePage" resultType="com.huiju.estateagents.entity.HelpActivity">
  101. SELECT
  102. ha.*
  103. FROM
  104. ta_help_activity ha
  105. <where>
  106. <if test="cityId != null and cityId != ''">
  107. and ha.city_id = #{cityId}
  108. </if>
  109. and ha.org_id=#{orgId}
  110. and ha.activity_status in (0, 1)
  111. </where>
  112. GROUP BY ha.help_activity_id
  113. order by ha.activity_status = 0 desc,
  114. ha.activity_status = 1 desc,
  115. ha.activity_status = 2 desc,
  116. ha.start_date asc
  117. </select>
  118. </mapper>