123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.huiju.estateagents.mapper.TaHousingResourcesMapper">
-
- <select id="listHousingResources" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
- SELECT
- *
- FROM
- (
- SELECT
- t.*,
- (
- CASE
- WHEN ( SELECT num_char_extract ( t.term_name, 2 ) + 0 ) = 0 THEN
- ( SELECT num_char_extract ( t.term_name, 2 ) ) ELSE ( SELECT num_char_extract ( t.term_name, 2 ) + 0 )
- END
- ) termNamePre,
- (
- CASE
- WHEN ( SELECT num_char_extract ( t.block_name, 2 ) + 0 ) = 0 THEN
- ( SELECT num_char_extract ( t.block_name, 2 ) ) ELSE ( SELECT num_char_extract ( t.block_name, 2 ) + 0 )
- END
- ) blockNamePre,
- (
- CASE
- WHEN ( SELECT num_char_extract ( t.unit_name, 2 ) + 0 ) = 0 THEN
- ( SELECT num_char_extract ( t.unit_name, 2 ) ) ELSE ( SELECT num_char_extract ( t.unit_name, 2 ) + 0 )
- END
- ) unitNamePre,
- t2.inside_area,
- t2.building_area,
- t2.apartment_name
- FROM
- ta_housing_resources t
- LEFT JOIN ta_building_apartment t2 ON t.apartment_id = t2.apartment_id
- LEFT JOIN ta_sales_batch t4 ON t.sales_batch_id = t4.sales_batch_id
- <if test="source == 'raiseChoose'">
- LEFT JOIN ta_raise_house t5 ON t.house_id = t5.house_id
- LEFT JOIN ta_raise_record t6 ON t6.raise_record_id = t5.raise_record_id
- LEFT JOIN ta_raise t7 ON t.sales_batch_id = t7.sales_batch_id
- </if>
- WHERE
- t.sales_batch_id = #{salesBatchId}
- AND t.org_id = #{orgId}
- AND t.`status` > 0
- AND t4.`status` = 1
- <if test = "source == 'raiseChoose'">
- AND ( t6.`status` != 0 OR t6.`status` IS NULL )
- AND (t.house_locking_status != 'locked' OR t.house_locking_status IS NULL)
- AND t7.raise_start_time <= now( ) AND t7.raise_end_time >= now()
- <if test="personId != null and personId != ''">
- AND (t6.person_id != #{personId} OR t6.person_id IS NULL)
- </if>
- </if>
- <choose>
- <when test=" endPrice != null and startPrice == null">
- AND t.price <= #{endPrice}
- </when>
- <when test=" startPrice != null and endPrice == null">
- AND t.price >= #{startPrice}
- </when>
- <when test="startPrice != null and endPrice != null ">
- AND ( t.price BETWEEN #{startPrice} AND #{endPrice} )
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="apartmentId != null and apartmentId != ''">
- AND t.apartment_id = #{apartmentId}
- </if>
- ) t5
- GROUP BY
- t5.house_id
- ORDER BY
- t5.termNamePre,
- t5.blockNamePre,
- t5.unitNamePre,
- ( SELECT num_char_extract ( t5.floor_name, 2 ) + 0 ) DESC,
- ( SELECT num_char_extract ( t5.room_name, 2 ) + 0)
- </select>
-
- <select id="listHousingResourcesForCms" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
- SELECT
- *
- FROM
- (
- SELECT
- t.house_id,
- (
- CASE
- WHEN ( SELECT num_char_extract ( t.term_name, 2 ) + 0 ) = 0 THEN
- ( SELECT num_char_extract ( t.term_name, 2 ) ) ELSE ( SELECT num_char_extract ( t.term_name, 2 ) + 0 )
- END
- ) termNamePre,
- (
- CASE
- WHEN ( SELECT num_char_extract ( t.block_name, 2 ) + 0 ) = 0 THEN
- ( SELECT num_char_extract ( t.block_name, 2 ) ) ELSE ( SELECT num_char_extract ( t.block_name, 2 ) + 0 )
- END
- ) blockNamePre,
- (
- CASE
- WHEN ( SELECT num_char_extract ( t.unit_name, 2 ) + 0 ) = 0 THEN
- ( SELECT num_char_extract ( t.unit_name, 2 ) ) ELSE ( SELECT num_char_extract ( t.unit_name, 2 ) + 0 )
- END
- ) unitNamePre,
- t.building_id,
- t.block_id,
- t.block_name,
- t.sales_batch_id,
- t.unit_id,
- t.unit_name,
- t.floor_id,
- t.floor_name,
- t.room_id,
- t.room_name,
- t.price,
- t.heat,
- t.real_heat,
- t.apartment_id,
- t.`status`,
- t.org_id,
- t2.inside_area,
- t2.building_area,
- t2.apartment_name,
- t3.term_id,
- t.term_name,
- t.raise_heat,
- t.raise_real_heat,
- t.house_locking_status
- FROM
- ta_housing_resources t
- LEFT JOIN ta_building_apartment t2 ON t.apartment_id = t2.apartment_id
- LEFT JOIN ta_building_block t3 ON t.block_id = t3.block_id
- WHERE
- t.sales_batch_id = #{salesBatchId}
- AND t.org_id = #{orgId}
- <choose>
- <when test=" endPrice != null and startPrice == null">
- AND t.price <= #{endPrice}
- </when>
- <when test=" startPrice != null and endPrice == null">
- AND t.price >= #{startPrice}
- </when>
- <when test="startPrice != null and endPrice != null ">
- AND ( t.price BETWEEN #{startPrice} AND #{endPrice} )
- </when>
- <otherwise>
- </otherwise>
- </choose>
- <if test="apartmentId != null and apartmentId != ''">
- AND t.apartment_id = #{apartmentId}
- </if>
- <choose>
- <when test="type == 1">
- AND t.`status` > 0
- </when>
- <otherwise>
- AND t.`status` > -1
- </otherwise>
- </choose>
-
- ) t5
- ORDER BY
- t5.termNamePre,
- t5.blockNamePre,
- t5.unitNamePre,
- ( SELECT num_char_extract ( t5.floor_name, 2 ) + 0 ) DESC,
- ( SELECT num_char_extract ( t5.room_name, 2 ) + 0)
- </select>
-
- <select id="listBuildApartmentBySalesBatchId" resultType="com.huiju.estateagents.entity.TaBuildingApartment">
- SELECT
- t3.apartment_id,
- t3.apartment_name,
- t3.apartment_type,
- t3.inside_area,
- t3.building_area,
- t2.apartment_id
- FROM
- (
- SELECT
- t.sales_batch_id,
- t.apartment_id
- FROM
- ta_housing_resources t
- WHERE
- t.sales_batch_id = #{salesBatchId}
- AND t.`status` > 0
- AND t.apartment_id IS NOT NULL
- GROUP BY
- t.apartment_id
- ) t2
- LEFT JOIN ta_building_apartment t3 ON t2.apartment_id = t3.apartment_id
- ORDER BY
- t3.apartment_name
- </select>
-
- <update id="updateForAddHeat" parameterType="java.lang.Integer">
- UPDATE ta_housing_resources t
- SET t.real_heat = IFNULL(t.real_heat, 0) + 1
- WHERE
- t.house_id = #{houseId}
- </update>
-
- <update id="updateForSubtractHeat" parameterType="java.lang.Integer">
- UPDATE ta_housing_resources t
- SET t.real_heat = IFNULL(t.real_heat, 0) - 1
- WHERE
- t.house_id = #{houseId}
- AND t.real_heat > 0
- </update>
-
- <update id="updateForSubtractRaiseHeat" parameterType="java.lang.Integer">
- UPDATE ta_housing_resources t
- SET t.raise_real_heat = IFNULL( t.raise_real_heat, 0 ) - 1
- WHERE
- t.house_id IN ( SELECT tr.house_id FROM ta_raise_house tr WHERE tr.raise_record_id = #{raiseRecordId})
- AND t.raise_real_heat > 0
- </update>
-
- <select id="getHousingDetailById" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
- SELECT
- t.house_id,
- t.building_id,
- t.block_id,
- t.block_name,
- t.sales_batch_id,
- t.unit_id,
- t.unit_name,
- t.floor_id,
- t.floor_name,
- t.room_id,
- t.room_name,
- t.price,
- t.heat,
- t.real_heat,
- t.apartment_id,
- t.`status`,
- t.org_id,
- t.term_id,
- t.term_name,
- t2.apartment_name,
- t2.inside_area,
- t2.building_area,
- t3.preselection_start_time,
- t3.preselection_end_time,
- t3.`status` saleBatchStatus,
- t3.display_house_price,
- t4.building_name buildingName
- FROM
- ta_housing_resources t
- LEFT JOIN ta_building_apartment t2 ON t.apartment_id = t2.apartment_id
- LEFT JOIN ta_sales_batch t3 ON t.sales_batch_id = t3.sales_batch_id
- LEFT JOIN ta_building t4 ON t.building_id = t4.building_id
- WHERE
- t.house_id = #{houseId}
- <if test="type != null and type == '1' ">
- AND t.`status` = 1
- AND t3.`status` = 1
- </if>
- </select>
-
- <select id="getHouseResourceList" resultType="com.huiju.estateagents.entity.TaHousingResources">
- SELECT
- t.* ,
- a.apartment_name,
- u.user_name as update_name
- FROM
- ta_housing_resources t
- LEFT JOIN ta_building_apartment a ON t.apartment_id = a.apartment_id
- LEFT JOIN ta_user u on t.update_user = u.user_id
- WHERE t.`status` > -1
- AND t.org_id = #{orgId}
- and t.building_id = #{buildingId}
- and t.sales_batch_id = #{salesBatchId}
- <if test="apartmentId != null and apartmentId != ''">
- AND t.apartment_id = #{apartmentId}
- </if>
- <if test="status != null">
- AND t.status = #{status}
- </if>
- <if test="houseId != null and houseId != ''">
- AND t.house_id like CONCAT('%',#{houseId}, '%')
- </if>
- <if test="termName != null and termName != ''">
- AND t.term_name like CONCAT('%',#{termName}, '%')
- </if>
- <if test="blockName != null and blockName != ''">
- AND t.block_name like CONCAT('%',#{blockName}, '%')
- </if>
- <if test="unitName != null and unitName != ''">
- AND t.unit_name like CONCAT('%',#{unitName}, '%')
- </if>
- <if test="floorName != null and floorName != ''">
- AND t.floor_name like CONCAT('%',#{floorName}, '%')
- </if>
- <if test="roomName != null and roomName != ''">
- AND t.room_name like CONCAT('%',#{roomName}, '%')
- </if>
- <if test="lockingStatus != null and lockingStatus != ''">
- AND t.house_locking_status = #{lockingStatus}
- </if>
- </select>
-
- <select id="selectHousingList" resultType="com.huiju.estateagents.entity.TaHousingResources">
- select * from ta_housing_resources where org_id = #{orgId} and sales_batch_id in
- <foreach collection="taSalesBatchList" item="taSalesBatch" open="(" close=")" separator=",">
- #{taSalesBatch.salesBatchId}
- </foreach>
- </select>
-
- <update id="batchUpdateRaiseHeat">
- UPDATE ta_housing_resources t
- SET t.raise_heat = #{raiseHeat},
- t.update_user = #{updateUser}
- WHERE
- t.org_id = #{orgId}
- AND t.sales_batch_id = #{salesBatchId}
- AND t.house_id IN
- <foreach collection="housingResourcesList" item="record" open="(" close=")" separator=",">
- #{record.houseId}
- </foreach>
- </update>
-
- <update id="batchUpdateHeat">
- UPDATE ta_housing_resources t
- SET t.heat = #{heat},
- t.update_user = #{updateUser}
- WHERE
- t.org_id = #{orgId}
- AND t.sales_batch_id = #{salesBatchId}
- AND t.house_id IN
- <foreach collection="housingResourcesList" item="record" open="(" close=")" separator=",">
- #{record.houseId}
- </foreach>
- </update>
-
- <select id="listHouseByRaiseRecordId" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
- SELECT
- t.*,
- t2.raise_house_id,
- t2.person_id lockingPersonId,
- t2.person_name lockingPersonName
- FROM
- ta_housing_resources t
- LEFT JOIN ta_raise_house t2 ON t.house_id = t2.house_id
- WHERE
- t.org_id = #{orgId}
- AND t.`status` != - 1
- AND t2.raise_record_id = #{raiseRecordId}
- ORDER BY
- t.create_date DESC
- </select>
-
- <select id="getHouseByRaiseHouseId" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
- SELECT
- t.*,
- t2.person_id lockingPersonId,
- t2.person_name lockingPersonName
- FROM
- ta_housing_resources t
- LEFT JOIN ta_raise_house t2 ON t.house_id = t2.house_id
- WHERE
- t2.raise_house_id = #{raiseHouseId}
- AND t2.org_id = #{orgId}
- AND t.`status` != -1
- </select>
-
- </mapper>
|