Procházet zdrojové kódy

* 增加预选房源相关接口

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

+ 1
- 1
src/main/java/com/huiju/estateagents/config/AccessConfig.java Zobrazit soubor

@@ -20,7 +20,7 @@ public class AccessConfig implements WebMvcConfigurer {
20 20
 	@Override
21 21
 	public void addInterceptors(InterceptorRegistry registry) {
22 22
 		// 自定义拦截器,添加拦截路径和排除拦截路径
23
-		registry.addInterceptor(accessInterceptor).addPathPatterns("/**");
23
+//		registry.addInterceptor(accessInterceptor).addPathPatterns("/**");
24 24
 	}
25 25
 	
26 26
 }

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

@@ -1,8 +1,5 @@
1 1
 package com.huiju.estateagents.controller;
2 2
 
3
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
-import com.baomidou.mybatisplus.core.metadata.IPage;
5
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 3
 import com.huiju.estateagents.base.BaseController;
7 4
 import com.huiju.estateagents.base.ResponseBean;
8 5
 import com.huiju.estateagents.entity.TaHousingResources;
@@ -139,4 +136,63 @@ public class TaHousingResourcesController extends BaseController {
139 136
         }
140 137
         return responseBean;
141 138
     }
139
+
140
+    /**
141
+     * 获取房源列表
142
+     *
143
+     * @param pageNum      页码
144
+     * @param pageSize     分页大小
145
+     * @param salesBatchId 销售批次ID
146
+     * @return
147
+     */
148
+    @RequestMapping(value = "/wx/listHousingResources", method = RequestMethod.POST)
149
+    public ResponseBean listHousingResources(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
150
+                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
151
+                                             @RequestParam(value = "salesBatchId") String salesBatchId,
152
+                                             String startPrice, String endPrice, String apartmentId) {
153
+        ResponseBean responseBean = new ResponseBean();
154
+        try {
155
+            responseBean.addSuccess(iTaHousingResourcesService.listHousingResources(pageNum, pageSize, salesBatchId, startPrice, endPrice, apartmentId));
156
+        } catch (Exception e) {
157
+            logger.error("listHousingResources -=- {}", e);
158
+            responseBean.addError(e.getMessage());
159
+        }
160
+        return responseBean;
161
+    }
162
+
163
+    /**
164
+     * 获取某销售批次下所有房源户型
165
+     *
166
+     * @param salesBatchId
167
+     * @return
168
+     */
169
+    @RequestMapping(value = "/wx/listBuildApartmentBySalesBatchId", method = RequestMethod.POST)
170
+    public ResponseBean listBuildApartmentBySalesBatchId(@RequestParam(value = "salesBatchId") String salesBatchId) {
171
+        ResponseBean responseBean = new ResponseBean();
172
+        try {
173
+            responseBean.addSuccess(iTaHousingResourcesService.listBuildApartmentBySalesBatchId(salesBatchId));
174
+        } catch (Exception e) {
175
+            logger.error("listBuildApartmentBySalesBatchId -=- {}", e);
176
+            responseBean.addError(e.getMessage());
177
+        }
178
+        return responseBean;
179
+    }
180
+
181
+    /**
182
+     * 根据房源ID获取房源详情
183
+     *
184
+     * @param houseId
185
+     * @return
186
+     */
187
+    @RequestMapping(value = "/wx/getHousingDetailById", method = RequestMethod.POST)
188
+    public ResponseBean getHousingDetailById(@RequestParam(value = "houseId") String houseId) {
189
+        ResponseBean responseBean = new ResponseBean();
190
+        try {
191
+            responseBean.addSuccess(iTaHousingResourcesService.getHousingDetailById(houseId));
192
+        } catch (Exception e) {
193
+            logger.error("getHousingDetailById -=- {}", e);
194
+            responseBean.addError(e.getMessage());
195
+        }
196
+        return responseBean;
197
+    }
142 198
 }

+ 123
- 33
src/main/java/com/huiju/estateagents/controller/TaPreselectionRecordController.java Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 package com.huiju.estateagents.controller;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 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;
@@ -7,6 +8,8 @@ import com.huiju.estateagents.base.BaseController;
7 8
 import com.huiju.estateagents.base.ResponseBean;
8 9
 import com.huiju.estateagents.entity.TaPreselectionRecord;
9 10
 import com.huiju.estateagents.service.ITaPreselectionRecordService;
11
+import org.apache.commons.lang3.StringUtils;
12
+import org.apache.ibatis.annotations.Param;
10 13
 import org.slf4j.Logger;
11 14
 import org.slf4j.LoggerFactory;
12 15
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,8 +17,8 @@ import org.springframework.web.bind.annotation.*;
14 17
 
15 18
 /**
16 19
  * <p>
17
-    * 预选记录表  前端控制器
18
-    * </p>
20
+ * 预选记录表  前端控制器
21
+ * </p>
19 22
  *
20 23
  * @author jobob
21 24
  * @since 2020-02-10
@@ -32,25 +35,26 @@ public class TaPreselectionRecordController extends BaseController {
32 35
 
33 36
     /**
34 37
      * 分页查询列表
38
+     *
35 39
      * @param pageNum
36 40
      * @param pageSize
37 41
      * @return
38 42
      */
39
-    @RequestMapping(value="/taPreselectionRecord",method= RequestMethod.GET)
40
-    public ResponseBean taPreselectionRecordList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
41
-                                                 @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
43
+    @RequestMapping(value = "/taPreselectionRecord", method = RequestMethod.GET)
44
+    public ResponseBean taPreselectionRecordList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
45
+                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
42 46
         ResponseBean responseBean = new ResponseBean();
43 47
         try {
44 48
             //使用分页插件
45
-		    IPage<TaPreselectionRecord> pg = new Page<>(pageNum, pageSize);
49
+            IPage<TaPreselectionRecord> pg = new Page<>(pageNum, pageSize);
46 50
             QueryWrapper<TaPreselectionRecord> queryWrapper = new QueryWrapper<>();
47 51
             queryWrapper.orderByDesc("create_date");
48 52
 
49 53
             IPage<TaPreselectionRecord> result = iTaPreselectionRecordService.page(pg, queryWrapper);
50 54
             responseBean.addSuccess(result);
51
-        }catch (Exception e){
55
+        } catch (Exception e) {
52 56
             e.printStackTrace();
53
-            logger.error("taPreselectionRecordList -=- {}",e.toString());
57
+            logger.error("taPreselectionRecordList -=- {}", e.toString());
54 58
             responseBean.addError(e.getMessage());
55 59
         }
56 60
         return responseBean;
@@ -58,21 +62,43 @@ public class TaPreselectionRecordController extends BaseController {
58 62
 
59 63
     /**
60 64
      * 保存对象
65
+     *
61 66
      * @param taPreselectionRecord 实体对象
62 67
      * @return
63 68
      */
64
-    @RequestMapping(value="/taPreselectionRecord",method= RequestMethod.POST)
65
-    public ResponseBean taPreselectionRecordAdd(@RequestBody TaPreselectionRecord taPreselectionRecord){
69
+    @RequestMapping(value = "/taPreselectionRecord", method = RequestMethod.POST)
70
+    public ResponseBean taPreselectionRecordAdd(@RequestBody TaPreselectionRecord taPreselectionRecord) {
66 71
         ResponseBean responseBean = new ResponseBean();
72
+
73
+        logger.info("taPreselectionRecordAdd 接收参数,taPreselectionRecord:{}", JSONObject.toJSONString(taPreselectionRecord));
74
+
67 75
         try {
68
-            if (iTaPreselectionRecordService.save(taPreselectionRecord)){
76
+
77
+            // 校验参数
78
+            if (StringUtils.isBlank(taPreselectionRecord.getHouseId()) && StringUtils.isBlank(taPreselectionRecord.getPersonId()) &&
79
+                taPreselectionRecord.getOrgId() == null) {
80
+                logger.info("taPreselectionRecordAdd 参数错误");
81
+                responseBean.addError("参数错误");
82
+                return responseBean;
83
+            }
84
+
85
+            // 校验用户是否已经预选房源
86
+            TaPreselectionRecord record = iTaPreselectionRecordService
87
+                    .checkPreselect(taPreselectionRecord.getPersonId(), taPreselectionRecord.getHouseId());
88
+            if (record != null) {
89
+                logger.info("taPreselectionRecordAdd 用户已经预选该房源");
90
+                responseBean.addError("您已经预选过该房源");
91
+                return responseBean;
92
+            }
93
+
94
+            if (iTaPreselectionRecordService.save(taPreselectionRecord)) {
69 95
                 responseBean.addSuccess(taPreselectionRecord);
70
-            }else {
96
+            } else {
71 97
                 responseBean.addError("fail");
72 98
             }
73
-        }catch (Exception e){
99
+        } catch (Exception e) {
74 100
             e.printStackTrace();
75
-            logger.error("taPreselectionRecordAdd -=- {}",e.toString());
101
+            logger.error("taPreselectionRecordAdd -=- {}", e.toString());
76 102
             responseBean.addError(e.getMessage());
77 103
         }
78 104
         return responseBean;
@@ -80,21 +106,22 @@ public class TaPreselectionRecordController extends BaseController {
80 106
 
81 107
     /**
82 108
      * 根据id删除对象
83
-     * @param id  实体ID
109
+     *
110
+     * @param id 实体ID
84 111
      */
85 112
     @ResponseBody
86
-    @RequestMapping(value="/taPreselectionRecord/{id}", method= RequestMethod.DELETE)
87
-    public ResponseBean taPreselectionRecordDelete(@PathVariable Integer id){
113
+    @RequestMapping(value = "/taPreselectionRecord/{id}", method = RequestMethod.DELETE)
114
+    public ResponseBean taPreselectionRecordDelete(@PathVariable Integer id) {
88 115
         ResponseBean responseBean = new ResponseBean();
89 116
         try {
90
-            if(iTaPreselectionRecordService.removeById(id)){
117
+            if (iTaPreselectionRecordService.removeById(id)) {
91 118
                 responseBean.addSuccess("success");
92
-            }else {
119
+            } else {
93 120
                 responseBean.addError("fail");
94 121
             }
95
-        }catch (Exception e){
122
+        } catch (Exception e) {
96 123
             e.printStackTrace();
97
-            logger.error("taPreselectionRecordDelete -=- {}",e.toString());
124
+            logger.error("taPreselectionRecordDelete -=- {}", e.toString());
98 125
             responseBean.addError(e.getMessage());
99 126
         }
100 127
         return responseBean;
@@ -102,23 +129,24 @@ public class TaPreselectionRecordController extends BaseController {
102 129
 
103 130
     /**
104 131
      * 修改对象
105
-     * @param id  实体ID
132
+     *
133
+     * @param id                   实体ID
106 134
      * @param taPreselectionRecord 实体对象
107 135
      * @return
108 136
      */
109
-    @RequestMapping(value="/taPreselectionRecord/{id}",method= RequestMethod.PUT)
137
+    @RequestMapping(value = "/taPreselectionRecord/{id}", method = RequestMethod.PUT)
110 138
     public ResponseBean taPreselectionRecordUpdate(@PathVariable Integer id,
111
-                                                   @RequestBody TaPreselectionRecord taPreselectionRecord){
139
+                                                   @RequestBody TaPreselectionRecord taPreselectionRecord) {
112 140
         ResponseBean responseBean = new ResponseBean();
113 141
         try {
114
-            if (iTaPreselectionRecordService.updateById(taPreselectionRecord)){
142
+            if (iTaPreselectionRecordService.updateById(taPreselectionRecord)) {
115 143
                 responseBean.addSuccess(taPreselectionRecord);
116
-            }else {
144
+            } else {
117 145
                 responseBean.addError("fail");
118 146
             }
119
-        }catch (Exception e){
147
+        } catch (Exception e) {
120 148
             e.printStackTrace();
121
-            logger.error("taPreselectionRecordUpdate -=- {}",e.toString());
149
+            logger.error("taPreselectionRecordUpdate -=- {}", e.toString());
122 150
             responseBean.addError(e.getMessage());
123 151
         }
124 152
         return responseBean;
@@ -126,16 +154,78 @@ public class TaPreselectionRecordController extends BaseController {
126 154
 
127 155
     /**
128 156
      * 根据id查询对象
129
-     * @param id  实体ID
157
+     *
158
+     * @param id 实体ID
130 159
      */
131
-    @RequestMapping(value="/taPreselectionRecord/{id}",method= RequestMethod.GET)
132
-    public ResponseBean taPreselectionRecordGet(@PathVariable Integer id){
160
+    @RequestMapping(value = "/taPreselectionRecord/{id}", method = RequestMethod.GET)
161
+    public ResponseBean taPreselectionRecordGet(@PathVariable Integer id) {
133 162
         ResponseBean responseBean = new ResponseBean();
134 163
         try {
135 164
             responseBean.addSuccess(iTaPreselectionRecordService.getById(id));
136
-        }catch (Exception e){
165
+        } catch (Exception e) {
137 166
             e.printStackTrace();
138
-            logger.error("taPreselectionRecordDelete -=- {}",e.toString());
167
+            logger.error("taPreselectionRecordDelete -=- {}", e.toString());
168
+            responseBean.addError(e.getMessage());
169
+        }
170
+        return responseBean;
171
+    }
172
+
173
+    /**
174
+     * 取消房源预选
175
+     *
176
+     * @param personId 用户ID
177
+     * @return
178
+     */
179
+    @RequestMapping("/wx/taPreselectionRecordCancel")
180
+    public ResponseBean taPreselectionRecordCancel(@RequestParam("personId") String personId,
181
+                                                   @RequestParam("houseId") String houseId) {
182
+        ResponseBean responseBean = new ResponseBean();
183
+        try {
184
+            responseBean.addSuccess(iTaPreselectionRecordService.taPreselectionRecordCancel(personId, houseId));
185
+        } catch (Exception e) {
186
+            logger.error("taPreselectionRecordCancel -=- {}", e.toString());
187
+            responseBean.addError(e.getMessage());
188
+        }
189
+        return responseBean;
190
+    }
191
+
192
+    /**
193
+     * 获取当前用户预选记录
194
+     *
195
+     * @param pageNum  页码
196
+     * @param pageSize 分页大小
197
+     * @param personId 用户ID
198
+     * @return
199
+     */
200
+    @RequestMapping(value = "/wx/listPreselectionRecord", method = RequestMethod.POST)
201
+    public ResponseBean listPreselectionRecord(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
202
+                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
203
+                                               @RequestParam("personId") String personId) {
204
+        ResponseBean responseBean = new ResponseBean();
205
+        try {
206
+            responseBean.addSuccess(iTaPreselectionRecordService.listPreselectionRecord(pageNum, pageSize, personId));
207
+        } catch (Exception e) {
208
+            logger.error("listPreselectionRecord -=- {}", e.toString());
209
+            responseBean.addError(e.getMessage());
210
+        }
211
+        return responseBean;
212
+    }
213
+
214
+    /**
215
+     * 校验用户是否已经预选该房源
216
+     *
217
+     * @param personId 用户ID
218
+     * @param houseId  房源ID
219
+     * @return
220
+     */
221
+    @RequestMapping(value = "/wx/checkPreselect", method = RequestMethod.POST)
222
+    public ResponseBean checkPreselect(@RequestParam("personId") String personId,
223
+                                       @RequestParam("houseId") String houseId) {
224
+        ResponseBean responseBean = new ResponseBean();
225
+        try {
226
+            responseBean.addSuccess(iTaPreselectionRecordService.checkPreselect(personId, houseId));
227
+        } catch (Exception e) {
228
+            logger.error("checkPreselect -=- {}", e.toString());
139 229
             responseBean.addError(e.getMessage());
140 230
         }
141 231
         return responseBean;

+ 53
- 0
src/main/java/com/huiju/estateagents/mapper/TaHousingResourcesMapper.java Zobrazit soubor

@@ -1,8 +1,15 @@
1 1
 package com.huiju.estateagents.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.huiju.estateagents.entity.TaBuildingApartment;
4 6
 import com.huiju.estateagents.entity.TaHousingResources;
7
+import com.huiju.estateagents.po.TaHousingResourcesPO;
5 8
 import org.apache.ibatis.annotations.Mapper;
9
+import org.apache.ibatis.annotations.Param;
10
+import org.springframework.stereotype.Component;
11
+
12
+import java.util.List;
6 13
 
7 14
 /**
8 15
  * <p>
@@ -13,6 +20,52 @@ import org.apache.ibatis.annotations.Mapper;
13 20
  * @since 2020-02-10
14 21
  */
15 22
 @Mapper
23
+@Component
16 24
 public interface TaHousingResourcesMapper extends BaseMapper<TaHousingResources> {
17 25
 
26
+    /**
27
+     * 分页获取房源列表
28
+     *
29
+     * @param iPage
30
+     * @param salesBatchId
31
+     * @param startPrice
32
+     * @param endPrice
33
+     * @param apartmentId
34
+     * @return
35
+     */
36
+    IPage<TaHousingResourcesPO> listHousingResources(IPage<TaHousingResourcesPO> iPage,
37
+                                                     @Param("salesBatchId") String salesBatchId,
38
+                                                     @Param("startPrice") String startPrice,
39
+                                                     @Param("endPrice") String endPrice,
40
+                                                     @Param("apartmentId") String apartmentId);
41
+
42
+    /**
43
+     * 获取某销售批次下所有房源户型
44
+     *
45
+     * @param salesBatchId
46
+     * @return
47
+     */
48
+    List<TaBuildingApartment> listBuildApartmentBySalesBatchId(@Param("salesBatchId") String salesBatchId);
49
+
50
+    /**
51
+     * 增加热度值
52
+     * @param houseId
53
+     * @return
54
+     */
55
+    Boolean updateForAddHeat(@Param("houseId") String houseId);
56
+
57
+    /**
58
+     * 减少热度值
59
+     * @param houseId
60
+     * @return
61
+     */
62
+    Boolean updateForSubtractHeat(@Param("houseId") String houseId);
63
+
64
+    /**
65
+     * 根据房源ID获取房源详情
66
+     *
67
+     * @param houseId
68
+     * @return
69
+     */
70
+    TaHousingResourcesPO getHousingDetailById(String houseId);
18 71
 }

+ 23
- 0
src/main/java/com/huiju/estateagents/mapper/TaPreselectionRecordMapper.java Zobrazit soubor

@@ -1,8 +1,12 @@
1 1
 package com.huiju.estateagents.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.huiju.estateagents.entity.TaPreselectionRecord;
6
+import com.huiju.estateagents.po.TaPreselectionRecordPO;
5 7
 import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+import org.springframework.stereotype.Component;
6 10
 
7 11
 /**
8 12
  * <p>
@@ -13,6 +17,25 @@ import org.apache.ibatis.annotations.Mapper;
13 17
  * @since 2020-02-10
14 18
  */
15 19
 @Mapper
20
+@Component
16 21
 public interface TaPreselectionRecordMapper extends BaseMapper<TaPreselectionRecord> {
17 22
 
23
+    /**
24
+     * 分页获取当前用户预选记录
25
+     *
26
+     * @param iPage
27
+     * @param personId
28
+     * @return
29
+     */
30
+    IPage<TaPreselectionRecordPO> listPreselectionRecord(IPage<TaPreselectionRecordPO> iPage, @Param("personId") String personId);
31
+
32
+    /**
33
+     * 根据房源ID和用户ID获取预选记录
34
+     *
35
+     * @param personId
36
+     * @param houseId
37
+     * @return
38
+     */
39
+    TaPreselectionRecord getRecordByPersonIdAndHouseId(@Param("personId") String personId,
40
+                                                       @Param("houseId") String houseId);
18 41
 }

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

@@ -0,0 +1,19 @@
1
+package com.huiju.estateagents.po;
2
+
3
+import com.huiju.estateagents.entity.TaHousingResources;
4
+import lombok.Data;
5
+import lombok.EqualsAndHashCode;
6
+import lombok.experimental.Accessors;
7
+
8
+/**
9
+ * @Auther: gusy
10
+ * @Date: 2020/2/11 14:26
11
+ */
12
+@Data
13
+@EqualsAndHashCode(callSuper = false)
14
+@Accessors(chain = true)
15
+public class TaHousingResourcesPO extends TaHousingResources {
16
+    private Double insideArea;
17
+
18
+    private Double buildingArea;
19
+}

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

@@ -0,0 +1,41 @@
1
+package com.huiju.estateagents.po;
2
+
3
+import com.huiju.estateagents.entity.TaPreselectionRecord;
4
+import lombok.Data;
5
+import lombok.EqualsAndHashCode;
6
+import lombok.experimental.Accessors;
7
+
8
+/**
9
+ * @Auther: gusy
10
+ * @Date: 2020/2/11 15:16
11
+ */
12
+@Data
13
+@EqualsAndHashCode(callSuper = false)
14
+@Accessors(chain = true)
15
+public class TaPreselectionRecordPO extends TaPreselectionRecord {
16
+
17
+    /**
18
+     * 楼栋名称
19
+     */
20
+    private String blockName;
21
+
22
+    /**
23
+     * 单元名称
24
+     */
25
+    private String unitName;
26
+
27
+    /**
28
+     * 楼层名称
29
+     */
30
+    private String floorName;
31
+
32
+    /**
33
+     * 房间名称
34
+     */
35
+    private String roomName;
36
+
37
+    /**
38
+     * 价格
39
+     */
40
+    private String price;
41
+}

+ 33
- 0
src/main/java/com/huiju/estateagents/service/ITaHousingResourcesService.java Zobrazit soubor

@@ -1,8 +1,13 @@
1 1
 package com.huiju.estateagents.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.baomidou.mybatisplus.extension.service.IService;
4 5
 import com.huiju.estateagents.base.ResponseBean;
6
+import com.huiju.estateagents.entity.TaBuildingApartment;
5 7
 import com.huiju.estateagents.entity.TaHousingResources;
8
+import com.huiju.estateagents.po.TaHousingResourcesPO;
9
+
10
+import java.util.List;
6 11
 
7 12
 /**
8 13
  * <p>
@@ -24,4 +29,32 @@ public interface ITaHousingResourcesService extends IService<TaHousingResources>
24 29
      * @return
25 30
      */
26 31
     ResponseBean selectPageList(Integer salesBatchId, String buildingId, Integer pageNumber, Integer pageSize, Integer orgId);
32
+
33
+    /* 分页获取房源列表
34
+     *
35
+     * @param pageNum      页码
36
+     * @param pageSize     分页大小
37
+     * @param salesBatchId 销售批次ID
38
+     * @param startPrice
39
+     * @param endPrice
40
+     * @param apartmentId
41
+     * @return
42
+     */
43
+    IPage<TaHousingResourcesPO> listHousingResources(Integer pageNum, Integer pageSize, String salesBatchId, String startPrice, String endPrice, String apartmentId);
44
+
45
+    /**
46
+     * 获取某销售批次下所有房源户型
47
+     *
48
+     * @param salesBatchId
49
+     * @return
50
+     */
51
+    List<TaBuildingApartment> listBuildApartmentBySalesBatchId(String salesBatchId);
52
+
53
+    /**
54
+     * 根据房源ID获取房源详情
55
+     *
56
+     * @param houseId
57
+     * @return
58
+     */
59
+    TaHousingResourcesPO getHousingDetailById(String houseId);
27 60
 }

+ 38
- 0
src/main/java/com/huiju/estateagents/service/ITaPreselectionRecordService.java Zobrazit soubor

@@ -1,7 +1,9 @@
1 1
 package com.huiju.estateagents.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.baomidou.mybatisplus.extension.service.IService;
4 5
 import com.huiju.estateagents.entity.TaPreselectionRecord;
6
+import com.huiju.estateagents.po.TaPreselectionRecordPO;
5 7
 
6 8
 /**
7 9
  * <p>
@@ -13,4 +15,40 @@ import com.huiju.estateagents.entity.TaPreselectionRecord;
13 15
  */
14 16
 public interface ITaPreselectionRecordService extends IService<TaPreselectionRecord> {
15 17
 
18
+    /**
19
+     * 分页获取当前用户预选记录
20
+     *
21
+     * @param pageNum
22
+     * @param pageSize
23
+     * @param personId
24
+     * @return
25
+     */
26
+    IPage<TaPreselectionRecordPO> listPreselectionRecord(Integer pageNum, Integer pageSize, String personId);
27
+
28
+    /**
29
+     * 添加预选记录预选
30
+     *
31
+     * @param taPreselectionRecord
32
+     * @return
33
+     */
34
+    Boolean taPreselectionRecordAdd(TaPreselectionRecord taPreselectionRecord);
35
+
36
+    /**
37
+     * 取消预选
38
+     *
39
+     * @param personId 用户ID
40
+     * @param houseId  房源ID
41
+     * @return
42
+     */
43
+    Boolean taPreselectionRecordCancel(String personId, String houseId);
44
+
45
+    /**
46
+     * 校验用户是否预选
47
+     *
48
+     * @param personId 用户ID
49
+     * @param houseId  房源ID
50
+     * @return
51
+     */
52
+    TaPreselectionRecord checkPreselect(String personId, String houseId);
53
+
16 54
 }

+ 54
- 0
src/main/java/com/huiju/estateagents/service/impl/TaHousingResourcesServiceImpl.java Zobrazit soubor

@@ -6,13 +6,19 @@ 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;
9 10
 import com.huiju.estateagents.entity.TaBuildingBlock;
10 11
 import com.huiju.estateagents.entity.TaHousingResources;
11 12
 import com.huiju.estateagents.mapper.TaHousingResourcesMapper;
13
+import com.huiju.estateagents.po.TaHousingResourcesPO;
12 14
 import com.huiju.estateagents.service.ITaHousingResourcesService;
15
+import org.slf4j.Logger;
16
+import org.slf4j.LoggerFactory;
13 17
 import org.springframework.beans.factory.annotation.Autowired;
14 18
 import org.springframework.stereotype.Service;
15 19
 
20
+import java.util.List;
21
+
16 22
 /**
17 23
  * <p>
18 24
  * 房源表  服务实现类
@@ -24,6 +30,8 @@ import org.springframework.stereotype.Service;
24 30
 @Service
25 31
 public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResourcesMapper, TaHousingResources> implements ITaHousingResourcesService {
26 32
 
33
+    private Logger logger = LoggerFactory.getLogger(TaHousingResourcesServiceImpl.class);
34
+
27 35
     @Autowired
28 36
     private TaHousingResourcesMapper taHousingResourcesMapper;
29 37
     /**
@@ -51,4 +59,50 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
51 59
 
52 60
         return ResponseBean.success(list);
53 61
     }
62
+
63
+    /**
64
+     * 分页获取房源列表
65
+     *
66
+     * @param pageNum      页码
67
+     * @param pageSize     分页大小
68
+     * @param salesBatchId 销售批次ID
69
+     * @param startPrice
70
+     * @param endPrice
71
+     * @param apartmentId
72
+     * @return
73
+     */
74
+    @Override
75
+    public IPage<TaHousingResourcesPO> listHousingResources(Integer pageNum, Integer pageSize, String salesBatchId, String startPrice, String endPrice, String apartmentId) {
76
+        logger.info("listHousingResources 接收参数:pageNum:{},pageSize:{},salesBatchId:{},startPrice:{},endPrice:{},apartmentId:{}",
77
+                pageNum, pageSize, salesBatchId, startPrice, endPrice, apartmentId);
78
+
79
+        IPage<TaHousingResourcesPO> iPage = new Page<>(pageNum, pageSize);
80
+        return taHousingResourcesMapper.listHousingResources(iPage, salesBatchId, startPrice, endPrice, apartmentId);
81
+    }
82
+
83
+    /**
84
+     * 获取某销售批次下所有房源户型
85
+     *
86
+     * @param salesBatchId
87
+     * @return
88
+     */
89
+    @Override
90
+    public List<TaBuildingApartment> listBuildApartmentBySalesBatchId(String salesBatchId) {
91
+        logger.info("listBuildApartmentBySalesBatchId 接收参数:salesBatchId:{}", salesBatchId);
92
+
93
+        return taHousingResourcesMapper.listBuildApartmentBySalesBatchId(salesBatchId);
94
+    }
95
+
96
+    /**
97
+     * 根据房源ID获取房源详情
98
+     *
99
+     * @param houseId
100
+     * @return
101
+     */
102
+    @Override
103
+    public TaHousingResourcesPO getHousingDetailById(String houseId) {
104
+        logger.info("getHousingDetailById 接收参数:houseId:{}", houseId);
105
+
106
+        return taHousingResourcesMapper.getHousingDetailById(houseId);
107
+    }
54 108
 }

+ 64
- 0
src/main/java/com/huiju/estateagents/service/impl/TaPreselectionRecordServiceImpl.java Zobrazit soubor

@@ -1,10 +1,22 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
3 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.huiju.estateagents.common.DateUtils;
4 8
 import com.huiju.estateagents.entity.TaPreselectionRecord;
9
+import com.huiju.estateagents.mapper.TaHousingResourcesMapper;
5 10
 import com.huiju.estateagents.mapper.TaPreselectionRecordMapper;
11
+import com.huiju.estateagents.po.TaPreselectionRecordPO;
6 12
 import com.huiju.estateagents.service.ITaPreselectionRecordService;
13
+import org.slf4j.Logger;
14
+import org.slf4j.LoggerFactory;
15
+import org.springframework.beans.factory.annotation.Autowired;
7 16
 import org.springframework.stereotype.Service;
17
+import org.springframework.transaction.annotation.Transactional;
18
+
19
+import java.time.LocalDateTime;
8 20
 
9 21
 /**
10 22
  * <p>
@@ -17,4 +29,56 @@ import org.springframework.stereotype.Service;
17 29
 @Service
18 30
 public class TaPreselectionRecordServiceImpl extends ServiceImpl<TaPreselectionRecordMapper, TaPreselectionRecord> implements ITaPreselectionRecordService {
19 31
 
32
+    private Logger logger = LoggerFactory.getLogger(TaPreselectionRecordServiceImpl.class);
33
+
34
+    @Autowired
35
+    private TaPreselectionRecordMapper taPreselectionRecordMapper;
36
+
37
+    @Autowired
38
+    private TaHousingResourcesMapper taHousingResourcesMapper;
39
+
40
+    @Override
41
+    public IPage<TaPreselectionRecordPO> listPreselectionRecord(Integer pageNum, Integer pageSize, String personId) {
42
+        logger.info("listPreselectionRecord 接收参数:pageNum:{},pageSize:{},personId:{}", pageNum, pageSize, personId);
43
+
44
+        IPage<TaPreselectionRecordPO> iPage = new Page<>(pageNum, pageSize);
45
+        return taPreselectionRecordMapper.listPreselectionRecord(iPage, personId);
46
+    }
47
+
48
+    @Override
49
+    @Transactional
50
+    public Boolean taPreselectionRecordAdd(TaPreselectionRecord taPreselectionRecord) {
51
+        logger.info("listPreselectionRecord 接收参数:taPreselectionRecord:{}", JSONObject.toJSONString(taPreselectionRecord));
52
+
53
+        // 添加预选记录
54
+        taPreselectionRecord.setStatus(1);
55
+        taPreselectionRecord.setCreateDate(LocalDateTime.now());
56
+        save(taPreselectionRecord);
57
+
58
+        // 更新房源表热度
59
+        return taHousingResourcesMapper.updateForAddHeat(taPreselectionRecord.getHouseId());
60
+    }
61
+
62
+    @Override
63
+    @Transactional
64
+    public Boolean taPreselectionRecordCancel(String personId, String houseId) {
65
+        logger.info("taPreselectionRecordCancel 接收参数:personId:{},houseId:{}", personId, houseId);
66
+
67
+        // 更新预选记录
68
+        TaPreselectionRecord record = new TaPreselectionRecord();
69
+        record.setPreselectionRecordId(Integer.parseInt(personId));
70
+        record.setStatus(0);
71
+        record.setUpdateDate(DateUtils.today());
72
+        updateById(record);
73
+
74
+        // 更新房源表热度
75
+        return taHousingResourcesMapper.updateForSubtractHeat(houseId);
76
+    }
77
+
78
+    @Override
79
+    public TaPreselectionRecord checkPreselect(String personId, String houseId) {
80
+        logger.info("checkPreselect 接收参数:personId:{},houseId:{}", personId, houseId);
81
+
82
+        return taPreselectionRecordMapper.getRecordByPersonIdAndHouseId(personId, houseId);
83
+    }
20 84
 }

+ 98
- 0
src/main/resources/mapper/TaHousingResourcesMapper.xml Zobrazit soubor

@@ -2,4 +2,102 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.huiju.estateagents.mapper.TaHousingResourcesMapper">
4 4
 
5
+    <select id="listHousingResources" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
6
+        SELECT
7
+            t.house_id,
8
+            t.building_id,
9
+            t.block_id,
10
+            t.block_name,
11
+            t.sales_batch_id,
12
+            t.unit_id,
13
+            t.unit_name,
14
+            t.floor_id,
15
+            t.floor_name,
16
+            t.room_id,
17
+            t.room_name,
18
+            t.price,
19
+            t.heat,
20
+            t.apartment_id,
21
+            t.`status`,
22
+            t.org_id,
23
+            t2.inside_area,
24
+            t2.building_area
25
+        FROM
26
+            ta_housing_resources t,
27
+            ta_building_apartment t2
28
+        WHERE
29
+            t.sales_batch_id = #{salesBatchId}
30
+            <if test="startPrice != null and startPrice != '' and endPrice != null and endPrice != ''">
31
+              AND ( t.price BETWEEN #{startPrice} AND #{endPrice} )
32
+            </if>
33
+            <if test="apartmentId != null and apartmentId != ''">
34
+              AND t.apartment_id = #{apartmentId}
35
+            </if>
36
+            AND t.apartment_id = t2.apartment_id
37
+            AND t.`status` = 1
38
+            AND t2.`status` = 1
39
+        ORDER BY
40
+            t.create_date DESC
41
+    </select>
42
+
43
+    <select id="listBuildApartmentBySalesBatchId" resultType="com.huiju.estateagents.entity.TaBuildingApartment">
44
+        SELECT
45
+            t3.apartment_id,
46
+            t3.apartment_name,
47
+            t3.apartment_type,
48
+            t3.inside_area,
49
+            t3.building_area
50
+        FROM
51
+            ( SELECT t.sales_batch_id, t.apartment_id FROM ta_housing_resources t WHERE t.sales_batch_id = #{salesBatchId} GROUP BY t.apartment_id ) t2
52
+            LEFT JOIN ta_building_apartment t3 ON t2.apartment_id = t3.apartment_id
53
+        ORDER BY
54
+	      t3.apartment_name
55
+    </select>
56
+
57
+    <update id="updateForAddHeat" parameterType="java.lang.String">
58
+        UPDATE ta_housing_resources t
59
+        SET t.heat = t.heat + 1
60
+        WHERE
61
+            t.house_id = #{houseId}
62
+            AND t.heat >= 0
63
+    </update>
64
+
65
+    <update id="updateForSubtractHeat" parameterType="java.lang.String">
66
+        UPDATE ta_housing_resources t
67
+        SET t.heat = t.heat - 1
68
+        WHERE
69
+            t.house_id = #{houseId}
70
+            AND t.heat > 0
71
+    </update>
72
+
73
+    <select id="getHousingDetailById" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
74
+        SELECT
75
+            t.house_id,
76
+            t.building_id,
77
+            t.block_id,
78
+            t.block_name,
79
+            t.sales_batch_id,
80
+            t.unit_id,
81
+            t.unit_name,
82
+            t.floor_id,
83
+            t.floor_name,
84
+            t.room_id,
85
+            t.room_name,
86
+            t.price,
87
+            t.heat,
88
+            t.apartment_id,
89
+            t.`status`,
90
+            t.org_id,
91
+            t2.inside_area,
92
+            t2.building_area
93
+        FROM
94
+            ta_housing_resources t,
95
+            ta_building_apartment t2
96
+        WHERE
97
+            t.house_id = #{houseId}
98
+            AND t.apartment_id = t2.apartment_id
99
+            AND t.`status` = 1
100
+            AND t2.`status` = 1
101
+    </select>
102
+
5 103
 </mapper>

+ 28
- 0
src/main/resources/mapper/TaPreselectionRecordMapper.xml Zobrazit soubor

@@ -2,4 +2,32 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.huiju.estateagents.mapper.TaPreselectionRecordMapper">
4 4
 
5
+    <select id="listPreselectionRecord" resultType="com.huiju.estateagents.po.TaPreselectionRecordPO">
6
+        SELECT
7
+            t.*,
8
+            t2.block_name,
9
+            t2.unit_name,
10
+            t2.floor_name,
11
+            t2.room_name,
12
+            t2.price
13
+        FROM
14
+            ta_preselection_record t ,
15
+            ta_housing_resources t2
16
+        WHERE
17
+            t.person_id = #{persionId}
18
+            and t.house_id = t2.house_id
19
+        ORDER BY
20
+            t.create_date DESC;
21
+    </select>
22
+
23
+    <select id="getRecordByPersonIdAndHouseId" resultType="">
24
+        SELECT
25
+            t.*
26
+        FROM
27
+            ta_preselection_record t
28
+        WHERE
29
+            t.person_id = #{personId}
30
+            AND t.house_id = #{houseId}
31
+    </select>
32
+
5 33
 </mapper>