TaPreselectionRecordMapper.xml 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.TaPreselectionRecordMapper">
  4. <select id="listPreselectionRecord" resultType="com.huiju.estateagents.po.TaPreselectionRecordPO">
  5. SELECT
  6. t3.*,
  7. t4.building_name,
  8. t5.`status` saleBatchStatus
  9. FROM
  10. (
  11. SELECT
  12. t.*,
  13. t2.term_name,
  14. t2.block_name,
  15. t2.unit_name,
  16. t2.floor_name,
  17. t2.room_name,
  18. t2.price,
  19. t2.apartment_id,
  20. t2.building_id buildingId,
  21. t2.`status` housingStatus,
  22. t2.sales_batch_id saleBatchId
  23. FROM
  24. ta_preselection_record t,
  25. ta_housing_resources t2
  26. WHERE
  27. t.person_id = #{personId}
  28. AND t.org_id = #{orgId}
  29. AND t.house_id = t2.house_id
  30. <if test="buildingId != null and buildingId != ''">
  31. AND t.building_id = #{buildingId}
  32. </if>
  33. <if test="salesBatchId != null and salesBatchId != ''">
  34. AND t2.sales_batch_id = #{salesBatchId}
  35. </if>
  36. <if test="apartmentId != null and apartmentId != ''">
  37. AND t2.apartment_id = #{apartmentId}
  38. </if>
  39. <if test="houseLockingStatus == 'locked'">
  40. AND t2.house_locking_status = 'locked'
  41. </if>
  42. <if test="houseLockingStatus == 'unlocked'">
  43. AND t2.house_locking_status != 'locked'
  44. </if>
  45. ) t3
  46. LEFT JOIN ta_building t4 ON t3.buildingId = t4.building_id
  47. LEFT JOIN ta_sales_batch t5 ON t3.saleBatchId = t5.sales_batch_id
  48. left join ta_raise_house t6 on t3.house_id = t6.house_id
  49. where 1=1
  50. <if test="customerLocked == 'mine'">
  51. AND t6.person_id = #{personId}
  52. </if>
  53. <if test="customerLocked == 'other'">
  54. AND t6.person_id != #{personId}
  55. </if>
  56. GROUP BY
  57. t6.house_id
  58. ORDER BY
  59. t3.create_date DESC
  60. </select>
  61. <select id="getRecordByPersonIdAndHouseId" resultType="com.huiju.estateagents.entity.TaPreselectionRecord">
  62. SELECT
  63. t.*
  64. FROM
  65. ta_preselection_record t
  66. WHERE
  67. t.person_id = #{personId}
  68. AND t.house_id = #{houseId}
  69. AND t.status = 1
  70. </select>
  71. <select id="selectPreSelectRecordList" resultType="com.huiju.estateagents.po.TaPreselectionRecordPO">
  72. SELECT
  73. *
  74. FROM
  75. (
  76. SELECT
  77. t.preselection_record_id,
  78. t.house_id,
  79. a.block_name,
  80. a.unit_name,
  81. a.floor_name,
  82. a.room_name,
  83. a.apartment_id,
  84. b.nickname AS nameOrnick,
  85. b.`name`,
  86. b.avatarurl,
  87. b.phone,
  88. a.term_name,
  89. t.`status`,
  90. t.update_date,
  91. t.building_id,
  92. t.sales_batch_id,
  93. e.apartment_name,
  94. b.person_id
  95. FROM
  96. ta_preselection_record t
  97. LEFT JOIN ta_housing_resources a ON t.house_id = a.house_id
  98. LEFT JOIN ta_person b ON t.person_id = b.person_id
  99. LEFT JOIN ta_building_apartment e ON a.apartment_id = e.apartment_id
  100. WHERE
  101. b.org_id = #{bo.orgId} and t.status != -1
  102. AND a.sales_batch_id = #{bo.salesBatchId}
  103. <if test="bo.termName != null and bo.termName != ''">
  104. AND a.term_name like CONCAT('%',#{bo.termName}, '%')
  105. </if>
  106. <if test="bo.blockName != null and bo.blockName != ''">
  107. AND a.block_name like CONCAT('%',#{bo.blockName}, '%')
  108. </if>
  109. <if test="bo.unitName != null and bo.unitName != ''">
  110. AND a.unit_name like CONCAT('%',#{bo.unitName}, '%')
  111. </if>
  112. <if test="bo.floorName != null and bo.floorName != ''">
  113. AND a.floor_name like CONCAT('%',#{bo.floorName}, '%')
  114. </if>
  115. <if test="bo.roomName != null and bo.roomName != ''">
  116. AND a.room_name like CONCAT('%',#{bo.roomName}, '%')
  117. </if>
  118. <if test="bo.houseId != null and bo.houseId !=''">
  119. AND t.house_id = #{houseId}
  120. </if>
  121. <if test="bo.phone != null and bo.phone != ''">
  122. AND b.phone = #{bo.phone}
  123. </if>
  124. <if test="bo.apartmentId != null and bo.apartmentId != ''">
  125. AND a.apartment_id = #{bo.apartmentId}
  126. </if>
  127. <if test="bo.status != null">
  128. AND t.status = #{bo.status}
  129. </if>
  130. <if test="bo.startTime != null and bo.startTime != ''">
  131. AND STR_TO_DATE(t.update_date, '%Y-%m-%d %H:%i:%s') &gt;= STR_TO_DATE(#{bo.startTime}, '%Y-%m-%d %H:%i:%s')
  132. </if>
  133. <if test="bo.endTime != null and bo.endTime != ''">
  134. AND STR_TO_DATE(t.update_date, '%Y-%m-%d %H:%i:%s') &lt;= STR_TO_DATE(#{bo.endTime}, '%Y-%m-%d %H:%i:%s')
  135. </if>
  136. ORDER BY
  137. t.create_date DESC
  138. ) t
  139. GROUP BY
  140. t.house_id,
  141. t.person_id
  142. </select>
  143. <update id="batchDeletePreselectRecord">
  144. UPDATE ta_preselection_record t
  145. SET t.`status` = - 1,
  146. t.update_date = now(),
  147. t.update_user = #{userId}
  148. WHERE
  149. t.org_id = #{orgId}
  150. AND t.preselection_record_id IN
  151. <foreach collection="preselectionRecordList" item="record" open="(" close=")" separator=",">
  152. #{record.preselectionRecordId}
  153. </foreach>
  154. </update>
  155. </mapper>