Procházet zdrojové kódy

* 优化房源预选接口

顾绍勇 před 5 roky
rodič
revize
1e58cc8058

+ 3
- 0
src/main/java/com/huiju/estateagents/controller/TaHousingResourcesController.java Zobrazit soubor

@@ -152,6 +152,7 @@ public class TaHousingResourcesController extends BaseController {
152 152
      * @param pageSize     分页大小
153 153
      * @param salesBatchId 销售批次ID
154 154
      * @return
155
+     * @author gushaoyong
155 156
      */
156 157
     @RequestMapping(value = "/wx/listHousingResources", method = RequestMethod.POST)
157 158
     public ResponseBean listHousingResources(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -173,6 +174,7 @@ public class TaHousingResourcesController extends BaseController {
173 174
      *
174 175
      * @param salesBatchId
175 176
      * @return
177
+     * @author gushaoyong
176 178
      */
177 179
     @RequestMapping(value = "/wx/listBuildApartmentBySalesBatchId", method = RequestMethod.POST)
178 180
     public ResponseBean listBuildApartmentBySalesBatchId(@RequestParam(value = "salesBatchId") String salesBatchId) {
@@ -191,6 +193,7 @@ public class TaHousingResourcesController extends BaseController {
191 193
      *
192 194
      * @param houseId
193 195
      * @return
196
+     * @author gushaoyong
194 197
      */
195 198
     @RequestMapping(value = "/wx/getHousingDetailById", method = RequestMethod.POST)
196 199
     public ResponseBean getHousingDetailById(@RequestParam(value = "houseId") String houseId,

+ 7
- 3
src/main/java/com/huiju/estateagents/controller/TaPreselectionRecordController.java Zobrazit soubor

@@ -39,6 +39,7 @@ public class TaPreselectionRecordController extends BaseController {
39 39
      * @param pageNum
40 40
      * @param pageSize
41 41
      * @return
42
+     * @author gushaoyong
42 43
      */
43 44
     @RequestMapping(value = "/taPreselectionRecord", method = RequestMethod.GET)
44 45
     public ResponseBean taPreselectionRecordList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -65,6 +66,7 @@ public class TaPreselectionRecordController extends BaseController {
65 66
      *
66 67
      * @param taPreselectionRecord 实体对象
67 68
      * @return
69
+     * @author gushaoyong
68 70
      */
69 71
     @RequestMapping(value = "/taPreselectionRecord", method = RequestMethod.POST)
70 72
     public ResponseBean taPreselectionRecordAdd(@RequestBody TaPreselectionRecord taPreselectionRecord) {
@@ -172,7 +174,7 @@ public class TaPreselectionRecordController extends BaseController {
172 174
         try {
173 175
             responseBean.addSuccess(iTaPreselectionRecordService.taPreselectionRecordCancel(personId, houseId));
174 176
         } catch (Exception e) {
175
-            logger.error("taPreselectionRecordCancel -=- {}", e.toString());
177
+            logger.error("taPreselectionRecordCancel -=- {}", e);
176 178
             responseBean.addError(e.getMessage());
177 179
         }
178 180
         return responseBean;
@@ -185,6 +187,7 @@ public class TaPreselectionRecordController extends BaseController {
185 187
      * @param pageSize 分页大小
186 188
      * @param personId 用户ID
187 189
      * @return
190
+     * @author gushaoyong
188 191
      */
189 192
     @RequestMapping(value = "/wx/listPreselectionRecord", method = RequestMethod.POST)
190 193
     public ResponseBean listPreselectionRecord(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -194,7 +197,7 @@ public class TaPreselectionRecordController extends BaseController {
194 197
         try {
195 198
             responseBean.addSuccess(iTaPreselectionRecordService.listPreselectionRecord(pageNum, pageSize, personId));
196 199
         } catch (Exception e) {
197
-            logger.error("listPreselectionRecord -=- {}", e.toString());
200
+            logger.error("listPreselectionRecord -=- {}", e);
198 201
             responseBean.addError(e.getMessage());
199 202
         }
200 203
         return responseBean;
@@ -206,6 +209,7 @@ public class TaPreselectionRecordController extends BaseController {
206 209
      * @param personId 用户ID
207 210
      * @param houseId  房源ID
208 211
      * @return
212
+     * @author gushaoyong
209 213
      */
210 214
     @RequestMapping(value = "/wx/checkPreselect", method = RequestMethod.POST)
211 215
     public ResponseBean checkPreselect(@RequestParam("personId") String personId,
@@ -214,7 +218,7 @@ public class TaPreselectionRecordController extends BaseController {
214 218
         try {
215 219
             responseBean.addSuccess(iTaPreselectionRecordService.checkPreselect(personId, houseId));
216 220
         } catch (Exception e) {
217
-            logger.error("checkPreselect -=- {}", e.toString());
221
+            logger.error("checkPreselect -=- {}", e);
218 222
             responseBean.addError(e.getMessage());
219 223
         }
220 224
         return responseBean;

+ 8
- 0
src/main/java/com/huiju/estateagents/po/TaHousingResourcesPO.java Zobrazit soubor

@@ -1,12 +1,14 @@
1 1
 package com.huiju.estateagents.po;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.TableField;
4
+import com.huiju.estateagents.entity.TaBuildingImg;
4 5
 import com.huiju.estateagents.entity.TaHousingResources;
5 6
 import lombok.Data;
6 7
 import lombok.EqualsAndHashCode;
7 8
 import lombok.experimental.Accessors;
8 9
 
9 10
 import java.time.LocalDateTime;
11
+import java.util.List;
10 12
 
11 13
 /**
12 14
  * @Auther: gusy
@@ -46,4 +48,10 @@ public class TaHousingResourcesPO extends TaHousingResources {
46 48
      * 销售批次状态
47 49
      */
48 50
     private Integer saleBatchStatus;
51
+
52
+    /**
53
+     * 户型图片列表
54
+     */
55
+    @TableField(exist = false)
56
+    private List<TaBuildingImg> buildingImgList;
49 57
 }

+ 20
- 0
src/main/java/com/huiju/estateagents/po/TaPreselectionRecordPO.java Zobrazit soubor

@@ -1,10 +1,14 @@
1 1
 package com.huiju.estateagents.po;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.TableField;
4
+import com.huiju.estateagents.entity.TaBuildingImg;
3 5
 import com.huiju.estateagents.entity.TaPreselectionRecord;
4 6
 import lombok.Data;
5 7
 import lombok.EqualsAndHashCode;
6 8
 import lombok.experimental.Accessors;
7 9
 
10
+import java.util.List;
11
+
8 12
 /**
9 13
  * @Auther: gusy
10 14
  * @Date: 2020/2/11 15:16
@@ -38,4 +42,20 @@ public class TaPreselectionRecordPO extends TaPreselectionRecord {
38 42
      * 价格
39 43
      */
40 44
     private String price;
45
+
46
+    /**
47
+     * 户型id
48
+     */
49
+    private String apartmentId;
50
+
51
+    /**
52
+     * 楼盘名称
53
+     */
54
+    private String buildingName;
55
+
56
+    /**
57
+     * 户型图片列表
58
+     */
59
+    @TableField(exist = false)
60
+    private List<TaBuildingImg> buildingImgList;
41 61
 }

+ 73
- 5
src/main/java/com/huiju/estateagents/service/impl/TaHousingResourcesServiceImpl.java Zobrazit soubor

@@ -6,17 +6,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 7
 import com.huiju.estateagents.base.ResponseBean;
8 8
 import com.huiju.estateagents.common.CommConstant;
9
-import com.huiju.estateagents.entity.TaBuildingApartment;
10
-import com.huiju.estateagents.entity.TaBuildingBlock;
11
-import com.huiju.estateagents.entity.TaHousingResources;
9
+import com.huiju.estateagents.entity.*;
10
+import com.huiju.estateagents.mapper.TaApartmentImgMapper;
11
+import com.huiju.estateagents.mapper.TaBuildingImgMapper;
12 12
 import com.huiju.estateagents.mapper.TaHousingResourcesMapper;
13
+import com.huiju.estateagents.mapper.TaPreselectionRecordMapper;
13 14
 import com.huiju.estateagents.po.TaHousingResourcesPO;
14 15
 import com.huiju.estateagents.service.ITaHousingResourcesService;
16
+import org.apache.commons.collections.CollectionUtils;
15 17
 import org.slf4j.Logger;
16 18
 import org.slf4j.LoggerFactory;
17 19
 import org.springframework.beans.factory.annotation.Autowired;
18 20
 import org.springframework.stereotype.Service;
19 21
 
22
+import java.util.ArrayList;
20 23
 import java.util.List;
21 24
 
22 25
 /**
@@ -35,6 +38,15 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
35 38
     @Autowired
36 39
     private TaHousingResourcesMapper taHousingResourcesMapper;
37 40
 
41
+    @Autowired
42
+    private TaPreselectionRecordMapper taPreselectionRecordMapper;
43
+
44
+    @Autowired
45
+    TaBuildingImgMapper taBuildingImgMapper;
46
+
47
+    @Autowired
48
+    TaApartmentImgMapper taApartmentImgMapper;
49
+
38 50
     /**
39 51
      * 分页获取房源详情数据
40 52
      *
@@ -91,7 +103,32 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
91 103
     public List<TaBuildingApartment> listBuildApartmentBySalesBatchId(String salesBatchId) {
92 104
         logger.info("listBuildApartmentBySalesBatchId 接收参数:salesBatchId:{}", salesBatchId);
93 105
 
94
-        return taHousingResourcesMapper.listBuildApartmentBySalesBatchId(salesBatchId);
106
+        // 获取户型列表
107
+        List<TaBuildingApartment> apartmentList = taHousingResourcesMapper.listBuildApartmentBySalesBatchId(salesBatchId);
108
+        if (CollectionUtils.isEmpty(apartmentList)) {
109
+            return null;
110
+        }
111
+
112
+        // 组装户型图片
113
+        List<TaBuildingApartment> resultList = new ArrayList<>();
114
+        List<TaBuildingImg> taBuildingImgList;
115
+        List<TaApartmentImg> buildingImg;
116
+        QueryWrapper<TaApartmentImg> apartmentImgQueryWrapper;
117
+        QueryWrapper<TaBuildingImg> buildingImgQueryWrapper;
118
+        for (TaBuildingApartment apartment : apartmentList) {
119
+            apartmentImgQueryWrapper = new QueryWrapper<>();
120
+            apartmentImgQueryWrapper.eq("apartment_id", apartment.getApartmentId());
121
+            buildingImg = taApartmentImgMapper.selectList(apartmentImgQueryWrapper);
122
+            for (TaApartmentImg apartmentImg : buildingImg) {
123
+                buildingImgQueryWrapper = new QueryWrapper<>();
124
+                buildingImgQueryWrapper.eq("img_id", apartmentImg.getImgId());
125
+                buildingImgQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_APARMENT);
126
+                taBuildingImgList = taBuildingImgMapper.selectList(buildingImgQueryWrapper);
127
+                apartment.setBuildingImgList(taBuildingImgList);
128
+                resultList.add(apartment);
129
+            }
130
+        }
131
+        return resultList;
95 132
     }
96 133
 
97 134
     /**
@@ -105,6 +142,37 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
105 142
     public TaHousingResourcesPO getHousingDetailById(String personId, String houseId) {
106 143
         logger.info("getHousingDetailById 接收参数:personId:{},houseId:{}", personId, houseId);
107 144
 
108
-        return taHousingResourcesMapper.getHousingDetailById(houseId, "1");
145
+        // 查询房源详情
146
+        TaHousingResourcesPO resourcesPO = taHousingResourcesMapper.getHousingDetailById(houseId, "1");
147
+        if (resourcesPO == null) {
148
+            return null;
149
+        }
150
+
151
+        // 获取该用户是否预选房源信息
152
+        TaPreselectionRecord taPreselectionRecord = taPreselectionRecordMapper.getRecordByPersonIdAndHouseId(personId, houseId);
153
+        if (taPreselectionRecord == null) {
154
+            resourcesPO.setIsPreselect(false);
155
+        } else {
156
+            resourcesPO.setIsPreselect(true);
157
+        }
158
+
159
+        // 获取户型图片列表
160
+        List<TaBuildingImg> taBuildingImgList = new ArrayList<>();
161
+        List<TaApartmentImg> buildingImg;
162
+        QueryWrapper<TaBuildingImg> buildingImgQueryWrapper;
163
+        QueryWrapper<TaApartmentImg>  apartmentImgQueryWrapper = new QueryWrapper<>();
164
+        apartmentImgQueryWrapper.eq("apartment_id", resourcesPO.getApartmentId());
165
+        buildingImg = taApartmentImgMapper.selectList(apartmentImgQueryWrapper);
166
+        for (TaApartmentImg apartmentImg : buildingImg) {
167
+            buildingImgQueryWrapper = new QueryWrapper<>();
168
+            buildingImgQueryWrapper.eq("img_id", apartmentImg.getImgId());
169
+            buildingImgQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_APARMENT);
170
+            taBuildingImgList = taBuildingImgMapper.selectList(buildingImgQueryWrapper);
171
+        }
172
+        if(CollectionUtils.isNotEmpty(taBuildingImgList)){
173
+            resourcesPO.setBuildingImgList(taBuildingImgList);
174
+        }
175
+
176
+        return resourcesPO;
109 177
     }
110 178
 }

+ 40
- 1
src/main/java/com/huiju/estateagents/service/impl/TaPreselectionRecordServiceImpl.java Zobrazit soubor

@@ -1,17 +1,24 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 8
 import com.huiju.estateagents.base.ResponseBean;
9
+import com.huiju.estateagents.common.CommConstant;
8 10
 import com.huiju.estateagents.common.DateUtils;
11
+import com.huiju.estateagents.entity.TaApartmentImg;
12
+import com.huiju.estateagents.entity.TaBuildingImg;
9 13
 import com.huiju.estateagents.entity.TaPreselectionRecord;
14
+import com.huiju.estateagents.mapper.TaApartmentImgMapper;
15
+import com.huiju.estateagents.mapper.TaBuildingImgMapper;
10 16
 import com.huiju.estateagents.mapper.TaHousingResourcesMapper;
11 17
 import com.huiju.estateagents.mapper.TaPreselectionRecordMapper;
12 18
 import com.huiju.estateagents.po.TaHousingResourcesPO;
13 19
 import com.huiju.estateagents.po.TaPreselectionRecordPO;
14 20
 import com.huiju.estateagents.service.ITaPreselectionRecordService;
21
+import org.apache.commons.collections.CollectionUtils;
15 22
 import org.slf4j.Logger;
16 23
 import org.slf4j.LoggerFactory;
17 24
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +26,8 @@ import org.springframework.stereotype.Service;
19 26
 import org.springframework.transaction.annotation.Transactional;
20 27
 
21 28
 import java.time.LocalDateTime;
29
+import java.util.ArrayList;
30
+import java.util.List;
22 31
 
23 32
 /**
24 33
  * <p>
@@ -39,12 +48,42 @@ public class TaPreselectionRecordServiceImpl extends ServiceImpl<TaPreselectionR
39 48
     @Autowired
40 49
     private TaHousingResourcesMapper taHousingResourcesMapper;
41 50
 
51
+    @Autowired
52
+    TaBuildingImgMapper taBuildingImgMapper;
53
+
54
+    @Autowired
55
+    TaApartmentImgMapper taApartmentImgMapper;
56
+
42 57
     @Override
43 58
     public IPage<TaPreselectionRecordPO> listPreselectionRecord(Integer pageNum, Integer pageSize, String personId) {
44 59
         logger.info("listPreselectionRecord 接收参数:pageNum:{},pageSize:{},personId:{}", pageNum, pageSize, personId);
45 60
 
46 61
         IPage<TaPreselectionRecordPO> iPage = new Page<>(pageNum, pageSize);
47
-        return taPreselectionRecordMapper.listPreselectionRecord(iPage, personId);
62
+        iPage = taPreselectionRecordMapper.listPreselectionRecord(iPage, personId);
63
+
64
+        List<TaPreselectionRecordPO> poList = iPage.getRecords();
65
+        if (CollectionUtils.isNotEmpty(poList)) {
66
+            List<TaPreselectionRecordPO> resultList = new ArrayList<>();
67
+            List<TaBuildingImg> taBuildingImgList;
68
+            List<TaApartmentImg> buildingImg;
69
+            QueryWrapper<TaApartmentImg> apartmentImgQueryWrapper;
70
+            QueryWrapper<TaBuildingImg> buildingImgQueryWrapper;
71
+            for (TaPreselectionRecordPO po : poList) {
72
+                apartmentImgQueryWrapper = new QueryWrapper<>();
73
+                apartmentImgQueryWrapper.eq("apartment_id", po.getApartmentId());
74
+                buildingImg = taApartmentImgMapper.selectList(apartmentImgQueryWrapper);
75
+                for (TaApartmentImg apartmentImg : buildingImg) {
76
+                    buildingImgQueryWrapper = new QueryWrapper<>();
77
+                    buildingImgQueryWrapper.eq("img_id", apartmentImg.getImgId());
78
+                    buildingImgQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_APARMENT);
79
+                    taBuildingImgList = taBuildingImgMapper.selectList(buildingImgQueryWrapper);
80
+                    po.setBuildingImgList(taBuildingImgList);
81
+                    resultList.add(po);
82
+                }
83
+            }
84
+            iPage.setRecords(resultList);
85
+        }
86
+        return iPage;
48 87
     }
49 88
 
50 89
     @Override

+ 14
- 5
src/main/resources/mapper/TaPreselectionRecordMapper.xml Zobrazit soubor

@@ -3,21 +3,30 @@
3 3
 <mapper namespace="com.huiju.estateagents.mapper.TaPreselectionRecordMapper">
4 4
 
5 5
     <select id="listPreselectionRecord" resultType="com.huiju.estateagents.po.TaPreselectionRecordPO">
6
+        SELECT
7
+            t3.*,
8
+            t4.building_name
9
+        FROM
10
+            (
6 11
         SELECT
7 12
             t.*,
8 13
             t2.block_name,
9 14
             t2.unit_name,
10 15
             t2.floor_name,
11 16
             t2.room_name,
12
-            t2.price
17
+            t2.price,
18
+            t2.apartment_id,
19
+            t2.building_id buildingId
13 20
         FROM
14
-            ta_preselection_record t ,
21
+            ta_preselection_record t,
15 22
             ta_housing_resources t2
16 23
         WHERE
17
-            t.person_id = #{persionId}
18
-            and t.house_id = t2.house_id
24
+            t.person_id = #{personId}
25
+            AND t.house_id = t2.house_id
19 26
         ORDER BY
20
-            t.create_date DESC;
27
+            t.create_date DESC
28
+            ) t3
29
+            LEFT JOIN ta_building t4 ON t3.buildingId = t4.building_id
21 30
     </select>
22 31
 
23 32
     <select id="getRecordByPersonIdAndHouseId" resultType="com.huiju.estateagents.entity.TaPreselectionRecord">