mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?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.panzhihua.service_community.dao.RentingHourseRegisterDao">
 
    <resultMap type="com.panzhihua.service_community.entity.RentingHourseRegister"
               id="RentingHourseRegisterBaseResultMap">
        <result property="id" column="id"/>
        <result property="streetId" column="street_id"/>
        <result property="communityId" column="community_id"/>
        <result property="villageId" column="village_id"/>
        <result property="villageName" column="village_name"/>
        <result property="alley" column="alley"/>
        <result property="houseNum" column="house_num"/>
        <result property="unitNo" column="unit_no"/>
        <result property="floor" column="floor"/>
        <result property="houseNo" column="house_no"/>
        <result property="buildingNo" column="building_no"/>
        <result property="code" column="code"/>
        <result property="address" column="address"/>
        <result property="authCode" column="auth_code"/>
        <result property="authStatus" column="auth_status"/>
        <result property="status" column="status"/>
        <result property="detailStatus" column="detail_status"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="constructArea" column="construct_area"/>
        <result property="path" column="path"/>
        <result property="seeHourseTelephone" column="see_hourse_telephone"/>
        <result property="title" column="title"/>
        <result property="brn" column="brn"/>
        <result property="lrn" column="lrn"/>
        <result property="wcn" column="wcn"/>
        <result property="roomType" column="room_type"/>
        <result property="monthlyRentMoney" column="monthly_rent_money"/>
        <result property="depositMoney" column="deposit_money"/>
        <result property="serverCharge" column="server_charge"/>
        <result property="dingMoney" column="ding_money"/>
        <result property="totalFloor" column="total_floor"/>
        <result property="orientation" column="orientation"/>
        <result property="decoration" column="decoration"/>
        <result property="seeHourseDate" column="see_hourse_date"/>
        <result property="hourseDescription" column="hourse_description"/>
        <result property="checkInRequirement" column="check_in_requirement"/>
        <result property="hourseItem" column="hourse_item"/>
        <result property="label" column="label"/>
        <result property="hourseOwnerName" column="hourse_owner_name"/>
        <result property="hourseIdCard" column="hourse_id_card"/>
        <result property="hoursePhone" column="hourse_phone"/>
        <result property="infoStatus" column="info_status"/>
        <result property="hourseOwnerWeixinAppid" column="hourse_owner_weixin_appid"/>
        <result property="hourseOwnerUserId" column="hourse_owner_user_id"/>
        <result property="tenantWeixinAppid" column="tenant_weixin_appid"/>
        <result property="tenantUserId" column="tenant_user_id"/>
        <result property="createAt" column="create_at"/>
        <result property="updateAt" column="update_at"/>
    </resultMap>
    <select id="pageRentingHouse"
            resultType="com.panzhihua.common.model.vos.community.rentingHouses.RentingHouseRegisterVO">
        SELECT t1.id, t1.title, t1.brn, t1.construct_area, t1.floor, t1.orientation, t1.decoration,
        t1.label, t1.address, t1.monthly_rent_money, t1.`status`, t1.detail_status, t1.auth_status, t1.auth_code, t2.url
        FROM renting_hourse_register t1
        LEFT JOIN (SELECT * FROM renting_hourse_file WHERE classification = 1 AND `type` = 1) t2 ON t1.id = t2.ref_id
        WHERE t1.community_id = ${pageRegisterDTO.communityId} AND t1.`status` = #{pageRegisterDTO.status}
        <if test="pageRegisterDTO.brn != null">
            <if test="pageRegisterDTO.moreBrn == null">
                AND t1.brn = #{pageRegisterDTO.brn}
            </if>
            <if test="pageRegisterDTO.moreBrn != null and pageRegisterDTO.moreBrn == 1">
                AND t1.brn &gt; #{pageRegisterDTO.brn}
            </if>
        </if>
        <if test="pageRegisterDTO.decoration != null">
            AND t1.decoration = #{pageRegisterDTO.decoration}
        </if>
        <if test="pageRegisterDTO.orientation != null">
            AND t1.orientation = #{pageRegisterDTO.orientation}
        </if>
        <if test="pageRegisterDTO.detailStatus != null">
            AND t1.detail_status = #{pageRegisterDTO.detailStatus}
        </if>
        <if test="pageRegisterDTO.minArea != null">
            AND t1.construct_area &gt;= #{pageRegisterDTO.minArea}
        </if>
        <if test="pageRegisterDTO.maxArea != null">
            AND t1.construct_area &lt;= #{pageRegisterDTO.maxArea}
        </if>
        <if test="pageRegisterDTO.minRentMoney != null">
            AND t1.monthly_rent_money &gt;= #{pageRegisterDTO.minRentMoney}
        </if>
        <if test="pageRegisterDTO.maxRentMoney != null">
            AND t1.monthly_rent_money &lt;= #{pageRegisterDTO.maxRentMoney}
        </if>
        <if test="pageRegisterDTO.keyword != null and pageRegisterDTO.keyword != &quot;&quot;">
            AND (
                t1.village_name LIKE CONCAT('%', #{pageRegisterDTO.keyword}, '%')
                OR t1.address LIKE CONCAT('%', #{pageRegisterDTO.keyword}, '%')
            )
        </if>
        GROUP BY id ORDER BY id DESC
    </select>
 
    <select id="nearby" resultType="com.panzhihua.common.model.vos.community.rentingHouses.RentingHouseRegisterVO">
        select t.id,title, brn, construct_area, floor, orientation, decoration, label, address, monthly_rent_money,
               `status`, detail_status, auth_status,t1.url,
               (POWER(MOD(ABS(longitude - #{nearbyDTO.longitude}),360),2) + POWER(ABS(latitude - #{nearbyDTO.latitude}),2)) AS distance
        from   renting_hourse_register t
        LEFT JOIN (SELECT * FROM renting_hourse_file WHERE classification = 1 AND `type` = 1) t1 ON t.id = t1.ref_id
        WHERE t.community_id = ${nearbyDTO.communityId} and t.status=2 and t.detail_status=3
          <if test="nearbyDTO.keyword !=null and nearbyDTO.keyword!=''">
              AND (
              village_name LIKE CONCAT('%', #{nearbyDTO.keyword}, '%')
              OR address LIKE CONCAT('%', #{nearbyDTO.keyword}, '%')
              )
          </if>
          and (longitude BETWEEN ${minX} AND ${maxX})
          and (latitude BETWEEN ${minY} AND ${maxY}) group by t.id order by distance ASC
    </select>
 
    <select id="pageRentingHouseApplet"
            resultType="com.panzhihua.common.model.vos.community.rentingHouses.RentingHouseRegisterVO">
        SELECT t.id, t.title, t.brn, t.construct_area, t.floor, t.orientation, t.decoration, t.label, t.address, t.monthly_rent_money,
        t.`status`, t.detail_status, t.auth_status,t1.url, t2.phone AS tenantTelephone, t.see_hourse_telephone, t.update_at
        <if test="pageRegisterDTO.longitude !=null and pageRegisterDTO.longitude !=''">
            ,(POWER(MOD(ABS(longitude - #{pageRegisterDTO.longitude}),360),2) + POWER(ABS(latitude - #{pageRegisterDTO.latitude}),2)) AS distance
        </if>
        FROM renting_hourse_register t
        LEFT JOIN (SELECT * FROM renting_hourse_file WHERE classification = 1 AND `type` = 1) t1 ON t.id = t1.ref_id
        LEFT JOIN sys_user t2 ON t.tenant_user_id = t2.user_id
        WHERE t.community_id = ${pageRegisterDTO.communityId}
        <if test="pageRegisterDTO.status == null and pageRegisterDTO.isMy == null">
            AND t.`status` = 2
        </if>
        <if test="pageRegisterDTO.status != null">
            AND t.`status` = #{pageRegisterDTO.status}
        </if>
        <if test="pageRegisterDTO.isMy != null and pageRegisterDTO.isMy == 1">
            AND t.hourse_owner_user_id = #{pageRegisterDTO.currentUserId}
        </if>
        <if test="pageRegisterDTO.brn != null">
            <if test="pageRegisterDTO.moreBrn == null">
                AND t.brn = #{pageRegisterDTO.brn}
            </if>
            <if test="pageRegisterDTO.moreBrn != null and pageRegisterDTO.moreBrn == 1">
                AND t.brn &gt; #{pageRegisterDTO.brn}
            </if>
        </if>
        <if test="pageRegisterDTO.decoration != null">
            AND t.decoration = #{pageRegisterDTO.decoration}
        </if>
        <if test="pageRegisterDTO.orientation != null">
            AND t.orientation = #{pageRegisterDTO.orientation}
        </if>
        <if test="pageRegisterDTO.detailStatus != null">
            AND t.detail_status = #{pageRegisterDTO.detailStatus}
        </if>
        <if test="pageRegisterDTO.minArea != null">
            AND t.construct_area &gt;= #{pageRegisterDTO.minArea}
        </if>
        <if test="pageRegisterDTO.maxArea != null">
            AND t.construct_area &lt;= #{pageRegisterDTO.maxArea}
        </if>
        <if test="pageRegisterDTO.minRentMoney != null">
            AND t.monthly_rent_money &gt;= #{pageRegisterDTO.minRentMoney}
        </if>
        <if test="pageRegisterDTO.maxRentMoney != null">
            AND t.monthly_rent_money &lt;= #{pageRegisterDTO.maxRentMoney}
        </if>
        <if test="pageRegisterDTO.keyword != null and pageRegisterDTO.keyword != &quot;&quot;">
            AND (
            t.village_name LIKE CONCAT('%', #{pageRegisterDTO.keyword}, '%')
            OR t.address LIKE CONCAT('%', #{pageRegisterDTO.keyword}, '%')
            )
        </if>
        group by t.id
        <if test="pageRegisterDTO.sort ==null">
            order by update_at desc
        </if>
        <if test="pageRegisterDTO.sort !=null">
            <if test="pageRegisterDTO.longitude !=null">
                <if test="pageRegisterDTO.sort==1">
                    order by distance DESC
                </if>
                <if test="pageRegisterDTO.sort==2">
                    order by distance ASC
                </if>
            </if>
            <if test="pageRegisterDTO.sort==3">
                order by monthly_rent_money DESC
            </if>
            <if test="pageRegisterDTO.sort==4">
                order by monthly_rent_money ASC
            </if>
        </if>
    </select>
 
</mapper>