123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?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.TaPreselectionRecordMapper">
-
- <select id="listPreselectionRecord" resultType="com.huiju.estateagents.po.TaPreselectionRecordPO">
- SELECT
- t3.*,
- t4.building_name,
- t5.`status` saleBatchStatus
- FROM
- (
- SELECT
- t.*,
- t2.term_name,
- t2.block_name,
- t2.unit_name,
- t2.floor_name,
- t2.room_name,
- t2.price,
- t2.apartment_id,
- t2.building_id buildingId,
- t2.`status` housingStatus,
- t2.sales_batch_id saleBatchId
- FROM
- ta_preselection_record t,
- ta_housing_resources t2
- WHERE
- t.person_id = #{personId}
- AND t.org_id = #{orgId}
- AND t.house_id = t2.house_id
- <if test="buildingId != null and buildingId != ''">
- AND t.building_id = #{buildingId}
- </if>
- <if test="salesBatchId != null and salesBatchId != ''">
- AND t2.sales_batch_id = #{salesBatchId}
- </if>
- <if test="apartmentId != null and apartmentId != ''">
- AND t2.apartment_id = #{apartmentId}
- </if>
- <if test="houseLockingStatus == 'locked'">
- AND t2.house_locking_status = 'locked'
- </if>
- <if test="houseLockingStatus == 'unlocked'">
- AND t2.house_locking_status != 'locked'
- </if>
- ) t3
- LEFT JOIN ta_building t4 ON t3.buildingId = t4.building_id
- LEFT JOIN ta_sales_batch t5 ON t3.saleBatchId = t5.sales_batch_id
- left join ta_raise_house t6 on t3.house_id = t6.house_id
- where 1=1
- <if test="customerLocked == 'mine'">
- AND t6.person_id = #{personId}
- </if>
- <if test="customerLocked == 'other'">
- AND t6.person_id != #{personId}
- </if>
- GROUP BY
- t6.house_id
- ORDER BY
- t3.create_date DESC
-
- </select>
-
- <select id="getRecordByPersonIdAndHouseId" resultType="com.huiju.estateagents.entity.TaPreselectionRecord">
- SELECT
- t.*
- FROM
- ta_preselection_record t
- WHERE
- t.person_id = #{personId}
- AND t.house_id = #{houseId}
- AND t.status = 1
- </select>
-
- <select id="selectPreSelectRecordList" resultType="com.huiju.estateagents.po.TaPreselectionRecordPO">
-
- SELECT
- *
- FROM
- (
- SELECT
- t.preselection_record_id,
- t.house_id,
- a.block_name,
- a.unit_name,
- a.floor_name,
- a.room_name,
- a.apartment_id,
- b.nickname AS nameOrnick,
- b.`name`,
- b.avatarurl,
- b.phone,
- a.term_name,
- t.`status`,
- t.update_date,
- t.building_id,
- t.sales_batch_id,
- e.apartment_name,
- b.person_id
- FROM
- ta_preselection_record t
- LEFT JOIN ta_housing_resources a ON t.house_id = a.house_id
- LEFT JOIN ta_person b ON t.person_id = b.person_id
- LEFT JOIN ta_building_apartment e ON a.apartment_id = e.apartment_id
- WHERE
- b.org_id = #{bo.orgId} and t.status != -1
- AND a.sales_batch_id = #{bo.salesBatchId}
- <if test="bo.termName != null and bo.termName != ''">
- AND a.term_name like CONCAT('%',#{bo.termName}, '%')
- </if>
- <if test="bo.blockName != null and bo.blockName != ''">
- AND a.block_name like CONCAT('%',#{bo.blockName}, '%')
- </if>
- <if test="bo.unitName != null and bo.unitName != ''">
- AND a.unit_name like CONCAT('%',#{bo.unitName}, '%')
- </if>
- <if test="bo.floorName != null and bo.floorName != ''">
- AND a.floor_name like CONCAT('%',#{bo.floorName}, '%')
- </if>
- <if test="bo.roomName != null and bo.roomName != ''">
- AND a.room_name like CONCAT('%',#{bo.roomName}, '%')
- </if>
- <if test="bo.houseId != null and bo.houseId !=''">
- AND t.house_id = #{houseId}
- </if>
- <if test="bo.phone != null and bo.phone != ''">
- AND b.phone = #{bo.phone}
- </if>
- <if test="bo.apartmentId != null and bo.apartmentId != ''">
- AND a.apartment_id = #{bo.apartmentId}
- </if>
- <if test="bo.status != null">
- AND t.status = #{bo.status}
- </if>
- <if test="bo.startTime != null and bo.startTime != ''">
- AND STR_TO_DATE(t.update_date, '%Y-%m-%d %H:%i:%s') >= STR_TO_DATE(#{bo.startTime}, '%Y-%m-%d %H:%i:%s')
- </if>
- <if test="bo.endTime != null and bo.endTime != ''">
- AND STR_TO_DATE(t.update_date, '%Y-%m-%d %H:%i:%s') <= STR_TO_DATE(#{bo.endTime}, '%Y-%m-%d %H:%i:%s')
- </if>
- ORDER BY
- t.create_date DESC
- ) t
- GROUP BY
- t.house_id,
- t.person_id
-
- </select>
-
- <update id="batchDeletePreselectRecord">
- UPDATE ta_preselection_record t
- SET t.`status` = - 1,
- t.update_date = now(),
- t.update_user = #{userId}
- WHERE
- t.org_id = #{orgId}
- AND t.preselection_record_id IN
- <foreach collection="preselectionRecordList" item="record" open="(" close=")" separator=",">
- #{record.preselectionRecordId}
- </foreach>
- </update>
-
- </mapper>
|