HousePriceMapper.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. </mapper>