TaHousingResourcesMapper.xml 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.TaHousingResourcesMapper">
  4. <select id="listHousingResources" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
  5. SELECT
  6. *
  7. FROM
  8. (
  9. SELECT
  10. t.house_id,
  11. t.building_id,
  12. t.block_id,
  13. t.block_name,
  14. t.sales_batch_id,
  15. t.unit_id,
  16. t.unit_name,
  17. t.floor_id,
  18. t.floor_name,
  19. t.room_id,
  20. t.room_name,
  21. t.price,
  22. t.heat,
  23. t.real_heat,
  24. t.apartment_id,
  25. t.`status`,
  26. t.org_id,
  27. t2.inside_area,
  28. t2.building_area,
  29. t2.apartment_name,
  30. t3.term_id,
  31. t4.term_name termName
  32. FROM
  33. ta_housing_resources t
  34. LEFT JOIN ta_building_apartment t2 ON t.apartment_id = t2.apartment_id
  35. LEFT JOIN ta_building_block t3 ON t.block_id = t3.block_id
  36. LEFT JOIN ta_building_term t4 ON t3.term_id = t4.term_id
  37. WHERE
  38. t.sales_batch_id = #{salesBatchId}
  39. <if test="startPrice != null and startPrice != '' and endPrice != null and endPrice != ''">
  40. AND ( t.price BETWEEN #{startPrice} AND #{endPrice} )
  41. </if>
  42. <if test="apartmentId != null and apartmentId != ''">
  43. AND t.apartment_id = #{apartmentId}
  44. </if>
  45. AND t.org_id = #{orgId}
  46. AND t.`status` > -1
  47. ) t5
  48. ORDER BY
  49. t5.termName,
  50. t5.block_name,
  51. t5.unit_name,
  52. t5.floor_name DESC,
  53. t5.room_name
  54. </select>
  55. <select id="listBuildApartmentBySalesBatchId" resultType="com.huiju.estateagents.entity.TaBuildingApartment">
  56. SELECT
  57. t3.apartment_id,
  58. t3.apartment_name,
  59. t3.apartment_type,
  60. t3.inside_area,
  61. t3.building_area
  62. FROM
  63. ( SELECT t.sales_batch_id, t.apartment_id FROM ta_housing_resources t WHERE t.sales_batch_id = #{salesBatchId} GROUP BY t.apartment_id ) t2
  64. LEFT JOIN ta_building_apartment t3 ON t2.apartment_id = t3.apartment_id
  65. ORDER BY
  66. t3.apartment_name
  67. </select>
  68. <update id="updateForAddHeat" parameterType="java.lang.String">
  69. UPDATE ta_housing_resources t
  70. SET t.real_heat = t.real_heat + 1
  71. WHERE
  72. t.house_id = #{houseId}
  73. AND t.real_heat >= 0
  74. </update>
  75. <update id="updateForSubtractHeat" parameterType="java.lang.String">
  76. UPDATE ta_housing_resources t
  77. SET t.real_heat = t.real_heat - 1
  78. WHERE
  79. t.house_id = #{houseId}
  80. AND t.real_heat > 0
  81. </update>
  82. <select id="getHousingDetailById" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
  83. SELECT
  84. t.house_id,
  85. t.building_id,
  86. t.block_id,
  87. t.block_name,
  88. t.sales_batch_id,
  89. t.unit_id,
  90. t.unit_name,
  91. t.floor_id,
  92. t.floor_name,
  93. t.room_id,
  94. t.room_name,
  95. t.price,
  96. t.heat,
  97. t.real_heat,
  98. t.apartment_id,
  99. t.`status`,
  100. t.org_id,
  101. t2.apartment_name,
  102. t2.inside_area,
  103. t2.building_area,
  104. t3.preselection_start_time,
  105. t3.preselection_end_time,
  106. t3.`status` saleBatchStatus,
  107. t4.building_name buildingName
  108. FROM
  109. ta_housing_resources t
  110. LEFT JOIN ta_building_apartment t2 ON t.apartment_id = t2.apartment_id
  111. LEFT JOIN ta_sales_batch t3 ON t.sales_batch_id = t3.sales_batch_id
  112. LEFT JOIN ta_building t4 ON t.building_id = t4.building_id
  113. WHERE
  114. t.house_id = #{houseId}
  115. <if test="type != null and type == '1' ">
  116. AND t.`status` = 1
  117. AND t3.`status` = 1
  118. </if>
  119. </select>
  120. <select id="getHouseResourceList" resultType="com.huiju.estateagents.entity.TaHousingResources">
  121. SELECT
  122. t.* ,
  123. a.apartment_name,
  124. u.user_name
  125. FROM
  126. ta_housing_resources t
  127. LEFT JOIN ta_building_apartment a ON t.apartment_id = a.apartment_id
  128. LEFT JOIN ta_user u on t.update_user = u.user_id
  129. WHERE t.`status` > -1
  130. AND t.org_id = #{orgId}
  131. and t.building_id = #{buildingId}
  132. and t.sales_batch_id = #{salesBatchId}
  133. <if test="apartmentId != null and apartmentId != ''">
  134. AND t.apartment_id = #{apartmentId}
  135. </if>
  136. <if test="status != null and status != ''">
  137. AND t.status = #{status}
  138. </if>
  139. <if test="houseId != null and houseId != ''">
  140. AND t.house_id like CONCAT('%',#{houseId}, '%')
  141. </if>
  142. <if test="termName != null and termName != ''">
  143. AND t.term_name like CONCAT('%',#{termName}, '%')
  144. </if>
  145. <if test="blockName != null and blockName != ''">
  146. AND t.block_name like CONCAT('%',#{blockName}, '%')
  147. </if>
  148. <if test="unitName != null and unitName != ''">
  149. AND t.unit_name like CONCAT('%',#{unitName}, '%')
  150. </if>
  151. <if test="floorName != null and floorName != ''">
  152. AND t.floor_name like CONCAT('%',#{floorName}, '%')
  153. </if>
  154. <if test="roomName != null and roomName != ''">
  155. AND t.room_name like CONCAT('%',#{roomName}, '%')
  156. </if>
  157. </select>
  158. </mapper>