HousePriceMapper.xml 2.1 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. <where>
  20. <if test="type != null and type != ''">
  21. AND t2.room_type = #{type}
  22. </if>
  23. </where>
  24. <where>
  25. <if test="houseName != null and houseName != ''">
  26. AND t2.room_name = #{houseName}
  27. </if>
  28. </where>
  29. <where>
  30. <if test="operatingTime != null and operatingTime != ''">
  31. AND t1.create_time BETWEEN SUBSTRING_INDEX(#{operatingTime}, ',', 1) and
  32. SUBSTRING_INDEX(#{operatingTime}, ',', -1)
  33. </if>
  34. </where>
  35. <where>
  36. <if test="priceTime != null and priceTime != ''">
  37. AND (substring_index(t1.set_date, ',', 1) BETWEEN SUBSTRING_INDEX(#{priceTime}, ',', 1) and
  38. SUBSTRING_INDEX(#{priceTime}, ',', -1)
  39. or
  40. substring_index(t1.set_date, ',', -1) BETWEEN SUBSTRING_INDEX(#{priceTime}, ',', 1) and
  41. SUBSTRING_INDEX(#{priceTime}, ',', -1)
  42. )
  43. </if>
  44. </where>
  45. <where>
  46. <if test="operatingName != null and operatingName != ''">
  47. AND a.`name` LIKE '%' #{operatingName} '%'
  48. </if>
  49. </where>
  50. GROUP BY t1.id
  51. ORDER BY t1.create_time DESC
  52. </select>
  53. </mapper>