HousePriceMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.template.mapper.HousePriceMapper">
  4. <select id="alterPriceRecord" resultType="com.template.model.vo.AlterPriceRecordVo">
  5. SELECT t2.room_type as houseType,
  6. t2.room_name AS houseName,
  7. group_concat(REPLACE(t1.set_date, ',', ' 至 ')) AS setDate,
  8. t1.price AS alterPrice,
  9. t1.original_price AS originalPrice,
  10. a.name as `name`,
  11. t1.create_time as date
  12. FROM house_price t1
  13. LEFT JOIN house t2 ON t1.house_id = t2.id
  14. and t2.deleted = 0
  15. LEFT JOIN admin a on a.id = t1.create_user
  16. and a.deleted = 0
  17. <where>
  18. t1.deleted = 0
  19. <if test="type != null and type != ''">
  20. AND t2.room_type = #{type}
  21. </if>
  22. <if test="houseName != null and houseName != ''">
  23. AND t2.room_name = #{houseName}
  24. </if>
  25. <if test="operatingTime != null and operatingTime != ''">
  26. AND t1.create_time BETWEEN SUBSTRING_INDEX(#{operatingTime}, ',', 1) and
  27. SUBSTRING_INDEX(#{operatingTime}, ',', -1)
  28. </if>
  29. <if test="priceTime != null and priceTime != ''">
  30. AND (substring_index(t1.set_date, ',', 1) BETWEEN SUBSTRING_INDEX(#{priceTime}, ',', 1) and
  31. SUBSTRING_INDEX(#{priceTime}, ',', -1)
  32. or
  33. substring_index(t1.set_date, ',', -1) BETWEEN SUBSTRING_INDEX(#{priceTime}, ',', 1) and
  34. SUBSTRING_INDEX(#{priceTime}, ',', -1)
  35. )
  36. </if>
  37. <if test="operatingName != null and operatingName != ''">
  38. AND a.`name` LIKE '%' #{operatingName} '%'
  39. </if>
  40. </where>
  41. GROUP BY t1.id
  42. ORDER BY t1.create_time DESC
  43. </select>
  44. <select id="housePrice" resultType="com.template.model.pojo.HousePrice">
  45. SELECT *
  46. FROM `house_price`
  47. WHERE #{endLocalDate} >= substring_index(set_date, ',', 1)
  48. and substring_index(set_date, ',', -1) >= #{localDate}
  49. and FIND_IN_SET(house_id, #{ids})
  50. and deleted = 0
  51. </select>
  52. <select id="queryExport" resultType="com.template.model.vo.AlterPriceRecordVo">
  53. SELECT t2.room_type as houseType,
  54. t2.room_name AS houseName,
  55. group_concat(REPLACE(t1.set_date, ',', ' 至 ')) AS setDate,
  56. t1.price AS alterPrice,
  57. t1.original_price AS originalPrice,
  58. a.name as `name`,
  59. t1.create_time as date
  60. FROM house_price t1
  61. LEFT JOIN house t2 ON t1.house_id = t2.id
  62. and t2.deleted = 0
  63. LEFT JOIN admin a on a.id = t1.create_user
  64. and a.deleted = 0
  65. <where>
  66. t1.deleted = 0
  67. <if test="type != null and type != ''">
  68. AND t2.room_type = #{type}
  69. </if>
  70. <if test="houseName != null and houseName != ''">
  71. AND t2.room_name = #{houseName}
  72. </if>
  73. <if test="operatingTime != null and operatingTime != ''">
  74. AND t1.create_time BETWEEN SUBSTRING_INDEX(#{operatingTime}, ',', 1) and
  75. SUBSTRING_INDEX(#{operatingTime}, ',', -1)
  76. </if>
  77. <if test="priceTime != null and priceTime != ''">
  78. AND (substring_index(t1.set_date, ',', 1) BETWEEN SUBSTRING_INDEX(#{priceTime}, ',', 1) and
  79. SUBSTRING_INDEX(#{priceTime}, ',', -1)
  80. or
  81. substring_index(t1.set_date, ',', -1) BETWEEN SUBSTRING_INDEX(#{priceTime}, ',', 1) and
  82. SUBSTRING_INDEX(#{priceTime}, ',', -1)
  83. )
  84. </if>
  85. <if test="operatingName != null and operatingName != ''">
  86. AND a.`name` LIKE '%' #{operatingName} '%'
  87. </if>
  88. </where>
  89. GROUP BY t1.id
  90. ORDER BY t1.create_time DESC
  91. </select>
  92. </mapper>