fuxingfan 3 år sedan
förälder
incheckning
18a602a7f4

+ 2
- 2
src/main/java/com/yunzhi/marketing/service/impl/TaBuildingServiceImpl.java Visa fil

@@ -884,10 +884,10 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
884 884
         }
885 885
         switch (orderBy) {
886 886
             case "price-asc":
887
-                orderBy = "tb.price ASC";
887
+                orderBy = "tbpt.start_price ASC";
888 888
                 break;
889 889
             case "price-desc":
890
-                orderBy = "tb.price DESC";
890
+                orderBy = "tbpt.end_price DESC";
891 891
                 break;
892 892
             case "openingDate-asc":
893 893
                 orderBy = "tb.opening_date ASC";

+ 41
- 44
src/main/resources/mapper/TaBuildingMapper.xml Visa fil

@@ -147,54 +147,12 @@
147 147
                 </if>
148 148
             ) as tb
149 149
 
150
-            <if test="(priceList != null and priceList.size > 0) or (buildingTypeList != null and buildingTypeList.length > 0)">
151
-                INNER JOIN
150
+                left JOIN
152 151
                 (
153 152
                 SELECT * FROM ta_building_project_type
154
-                <trim prefix="where" prefixOverrides="and | or">
155
-
156
-                    <if test="priceList != null">
157
-                        <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
158
-                            (
159
-                                <if test='priceArr[0] != null and priceArr[0] != ""'>
160
-                                    <![CDATA[ start_price > ${priceArr[0]}  ]]>
161
-                                </if>
162
-                                <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
163
-                                    AND
164
-                                </if>
165
-                                <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
166
-                                    <![CDATA[ start_price <= ${priceArr[1]}  ]]>
167
-                                </if>
168
-                            )  or
169
-                            (
170
-                            <if test='priceArr[0] != null and priceArr[0] != ""'>
171
-                                <![CDATA[ end_price > ${priceArr[0]}  ]]>
172
-                            </if>
173
-                            <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
174
-                                AND
175
-                            </if>
176
-                            <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
177
-                                <![CDATA[ end_price <= ${priceArr[1]}  ]]>
178
-                            </if>
179
-                            )
180
-                        </foreach>
181
-                    </if>
182
-
183
-                    <if test="priceType != null and priceType != ''">
184
-                        and price_type = #{priceType}
185
-                    </if>
186
-
187
-                    <if test="buildingTypeList != null and buildingTypeList.length > 0">
188
-                        AND building_type_id in
189
-                        <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
190
-                            #{buildingType}
191
-                        </foreach>
192
-                    </if>
193
-                </trim>
194 153
                 GROUP BY building_id
195 154
                 )
196 155
                 AS tbpt ON tb.building_id = tbpt.building_id
197
-            </if>
198 156
 
199 157
             <if test="(areaList != null and areaList.size > 0) or (houseTypeList != null and houseTypeList.length > 0)">
200 158
                 INNER JOIN
@@ -227,7 +185,46 @@
227 185
                 GROUP BY building_id
228 186
                 ) as tba ON tb.building_id = tba.building_id
229 187
             </if>
230
-            WHERE tb.org_id = #{orgId}
188
+        <trim prefix="where" prefixOverrides="and | or">
189
+            <if test="priceList != null">
190
+                <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
191
+                    (
192
+                    <if test='priceArr[0] != null and priceArr[0] != ""'>
193
+                        <![CDATA[ tbpt.start_price > ${priceArr[0]}  ]]>
194
+                    </if>
195
+                    <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
196
+                        AND
197
+                    </if>
198
+                    <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
199
+                        <![CDATA[ tbpt.start_price <= ${priceArr[1]}  ]]>
200
+                    </if>
201
+                    )  or
202
+                    (
203
+                    <if test='priceArr[0] != null and priceArr[0] != ""'>
204
+                        <![CDATA[ tbpt.end_price > ${priceArr[0]}  ]]>
205
+                    </if>
206
+                    <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
207
+                        AND
208
+                    </if>
209
+                    <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
210
+                        <![CDATA[ tbpt.end_price <= ${priceArr[1]}  ]]>
211
+                    </if>
212
+                    )
213
+                </foreach>
214
+            </if>
215
+
216
+            and tb.org_id = #{orgId}
217
+            <if test="priceType != null and priceType != ''">
218
+                and tbpt.price_type = #{priceType}
219
+            </if>
220
+
221
+            <if test="buildingTypeList != null and buildingTypeList.length > 0">
222
+                AND tbpt.building_type_id in
223
+                <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
224
+                    #{buildingType}
225
+                </foreach>
226
+            </if>
227
+        </trim>
231 228
             ORDER BY ${orderBy}
232 229
     </select>
233 230