TaRaiseRecordMapper.xml 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.TaRaiseRecordMapper">
  4. <select id="listHousingRaiseByCondition" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
  5. SELECT
  6. t.*,
  7. t4.apartment_name,
  8. t2.raise_record_id,
  9. t5.user_name updateName
  10. FROM
  11. ta_housing_resources t
  12. LEFT JOIN ta_raise_house t2 ON t.house_id = t2.house_id
  13. LEFT JOIN ta_raise_record t3 ON t2.raise_record_id = t3.raise_record_id
  14. LEFT JOIN ta_building_apartment t4 ON t.apartment_id = t4.apartment_id
  15. LEFT JOIN ta_user t5 ON t5.user_id = t.update_user
  16. WHERE
  17. t.org_id = #{bo.orgId}
  18. AND t.`status` != - 1
  19. <if test="bo.salesBatchId != null and bo.salesBatchId != ''">
  20. AND t.sales_batch_id = #{bo.salesBatchId}
  21. </if>
  22. <if test="bo.termName != null and bo.termName != ''">
  23. AND t.term_name like CONCAT('%',#{bo.termName}, '%')
  24. </if>
  25. <if test="bo.blockName != null and bo.blockName != ''">
  26. AND t.block_name like CONCAT('%',#{bo.blockName}, '%')
  27. </if>
  28. <if test="bo.unitName != null and bo.unitName != ''">
  29. AND t.unit_name like CONCAT('%',#{bo.unitName}, '%')
  30. </if>
  31. <if test="bo.floorName != null and bo.floorName != ''">
  32. AND t.floor_name like CONCAT('%',#{bo.floorName}, '%')
  33. </if>
  34. <if test="bo.roomName != null and bo.roomName != ''">
  35. AND t.room_name like CONCAT('%',#{bo.roomName}, '%')
  36. </if>
  37. <if test="bo.status != null">
  38. AND t.`status` = #{bo.status}
  39. </if>
  40. <if test="bo.lockingStatus == 'locked'">
  41. AND t.house_locking_status = #{bo.lockingStatus}
  42. </if>
  43. <if test="bo.lockingStatus == 'unlocked'">
  44. AND (t.house_locking_status = #{bo.lockingStatus} || t.house_locking_status is null)
  45. </if>
  46. <if test="bo.apartmentId != null and bo.apartmentId != ''">
  47. AND t.apartment_id = #{bo.apartmentId}
  48. </if>
  49. <if test="bo.houseId != null">
  50. AND t.house_id = #{bo.houseId}
  51. </if>
  52. GROUP BY
  53. t.house_id
  54. ORDER BY
  55. t.raise_real_heat DESC
  56. </select>
  57. <select id="listRaiseRecordByCondition" resultType="com.huiju.estateagents.entity.TaRaiseRecord">
  58. SELECT
  59. t.*,
  60. t3.house_id,
  61. t3.term_name,
  62. t3.block_name,
  63. t3.unit_name,
  64. t3.floor_name,
  65. t3.room_name,
  66. t3.apartment_id,
  67. t4.apartment_name,
  68. t5.tel personTel,
  69. t5.nickname,
  70. t5.avatarurl
  71. FROM
  72. ta_raise_record t
  73. LEFT JOIN ta_raise_house t2 ON t.raise_record_id = t2.raise_record_id
  74. LEFT JOIN ta_housing_resources t3 ON t2.house_id = t3.house_id
  75. LEFT JOIN ta_building_apartment t4 ON t3.apartment_id = t4.apartment_id
  76. LEFT JOIN ta_person t5 ON t.person_id = t5.person_id
  77. WHERE
  78. t.org_id = #{bo.orgId}
  79. AND t.`status` != - 1
  80. AND t3.`status` != - 1
  81. <if test="bo.raiseId != null and bo.raiseId != ''">
  82. AND t.raise_id =#{bo.raiseId}
  83. </if>
  84. <if test="bo.houseId != null and bo.houseId != ''">
  85. AND t3.house_id = #{bo.houseId}
  86. </if>
  87. <if test="bo.raiseRecordId != null and bo.raiseRecordId != ''">
  88. AND t.raise_record_id = #{bo.raiseRecordId}
  89. </if>
  90. <if test="bo.termName != null and bo.termName != ''">
  91. AND t3.term_name like CONCAT('%',#{bo.termName}, '%')
  92. </if>
  93. <if test="bo.blockName != null and bo.blockName != ''">
  94. AND t3.block_name like CONCAT('%',#{bo.blockName}, '%')
  95. </if>
  96. <if test="bo.unitName != null and bo.unitName != ''">
  97. AND t3.unit_name like CONCAT('%',#{bo.unitName}, '%')
  98. </if>
  99. <if test="bo.floorName != null and bo.floorName != ''">
  100. AND t3.floor_name like CONCAT('%',#{bo.floorName}, '%')
  101. </if>
  102. <if test="bo.roomName != null and bo.roomName != ''">
  103. AND t3.room_name like CONCAT('%',#{bo.roomName}, '%')
  104. </if>
  105. <if test="bo.status != null">
  106. AND t.status = #{bo.status}
  107. </if>
  108. <if test="bo.lockingStatus != null and bo.lockingStatus != ''">
  109. AND t.house_locking_status = #{bo.lockingStatus}
  110. </if>
  111. <if test="bo.tel != null and bo.tel != ''">
  112. AND t.tel like CONCAT('%',#{bo.tel} , '%')
  113. </if>
  114. <if test="bo.personTel != null and bo.personTel != ''">
  115. AND t5.tel like CONCAT('%',#{bo.personTel} , '%')
  116. </if>
  117. <if test="bo.payStatus != null and bo.payStatus != ''">
  118. AND t.pay_status = #{bo.payStatus}
  119. </if>
  120. <if test="bo.payType != null and bo.payType != ''">
  121. AND t.pay_type = #{bo.payType}
  122. </if>
  123. <if test = "bo.startTime != null and bo.startTime != ''">
  124. AND t.create_date &gt;= STR_TO_DATE(#{bo.startTime}, '%Y-%m-%d %H:%i:%s')
  125. </if>
  126. <if test = "bo.endTime != null and bo.endTime != ''">
  127. AND t.create_date &lt;= STR_TO_DATE(#{bo.endTime}, '%Y-%m-%d %H:%i:%s')
  128. </if>
  129. <if test="bo.personName != null and bo.personName != ''">
  130. AND t.name = #{bo.personName}
  131. </if>
  132. GROUP BY
  133. t2.raise_record_id
  134. ORDER BY
  135. t.create_date DESC
  136. </select>
  137. <select id ="listRaiseOrderByCondition" resultType="com.huiju.estateagents.entity.TaRaiseRecord">
  138. SELECT
  139. t.*,
  140. t2.order_id,
  141. t2.pay_time,
  142. t2.trade_no,
  143. t2.transaction_id,
  144. t4.refund_no,
  145. t4.order_id as refunded_order_id,
  146. t2.total_fee
  147. FROM
  148. ta_raise_record t
  149. INNER JOIN ta_order t2 ON t.order_id = t2.order_id
  150. LEFT JOIN ta_person t3 ON t2.person_id = t3.person_id
  151. left join ta_order t4 on t2.order_id = t4.parent_order_id
  152. WHERE
  153. t.org_id = #{bo.orgId}
  154. AND t.`status` != - 1
  155. <if test = "bo.raiseId != null and bo.raiseId != ''">
  156. AND t.raise_id = #{bo.raiseId}
  157. </if>
  158. <if test = "bo.orderId != null and bo.orderId != ''">
  159. AND t2.order_id = #{bo.orderId}
  160. </if>
  161. <if test = "bo.refundedOrderId != null and bo.refundedOrderId != ''">
  162. AND t4.order_id = #{bo.refundedOrderId}
  163. </if>
  164. <if test = "bo.raiseRecordId != null and bo.raiseRecordId != ''">
  165. AND t.raise_record_id = #{bo.raiseRecordId}
  166. </if>
  167. <if test = "bo.tel != null and bo.tel != ''">
  168. AND t.tel like CONCAT('%',#{bo.tel} , '%')
  169. </if>
  170. <if test = "bo.personTel != null and bo.personTel != ''">
  171. AND t3.tel like CONCAT('%',#{bo.personTel} , '%')
  172. </if>
  173. <if test = "bo.transactionId != null and bo.transactionId != ''">
  174. AND t2.transaction_id = #{bo.transactionId}
  175. </if>
  176. <if test = "bo.tradeNo != null and bo.tradeNo != ''">
  177. AND t2.trade_no = #{bo.tradeNo}
  178. </if>
  179. <if test = "bo.refundNo != null and bo.refundNo != ''">
  180. AND t2.refund_no = #{bo.refundNo}
  181. </if>
  182. <if test = "bo.payStatus == 'paid'">
  183. AND t.pay_status IN ('refunded','paid')
  184. </if>
  185. <if test = "bo.payStatus == 'refunded'">
  186. AND t.pay_status IN ('refunded','change')
  187. </if>
  188. <if test = "bo.payStartTime != null and bo.payStartTime != ''">
  189. AND t2.pay_time &gt;= STR_TO_DATE(#{bo.payStartTime}, '%Y-%m-%d %H:%i:%s')
  190. </if>
  191. <if test = "bo.payEndTime != null and bo.payEndTime != ''">
  192. AND t2.pay_time &lt;= STR_TO_DATE(#{bo.payEndTime}, '%Y-%m-%d %H:%i:%s')
  193. </if>
  194. ORDER BY
  195. t.create_date DESC
  196. </select>
  197. <select id="getUserInfo" resultType="com.huiju.estateagents.entity.TaRaiseRecord">
  198. select a.nickname as nickname, a.`name` as name, a.phone as personTel, t.tel, t.idcard from ta_raise_record t
  199. left join ta_person a on t.person_id = a.person_id
  200. where
  201. t.raise_record_id = #{raiseRecordId} and t.org_id = #{orgId}
  202. </select>
  203. <update id="addHouseNum">
  204. UPDATE ta_raise_record t
  205. SET t.house_num = IFNULL ( t.house_num, 0 ) + 1,
  206. t.update_date = now( ),
  207. t.update_user_name = #{updateUserName}
  208. WHERE
  209. t.raise_record_id = #{raiseRecordId}
  210. AND t.org_id = #{orgId}
  211. AND t.`status` != -1
  212. </update>
  213. </mapper>