Просмотр исходного кода

* 添加预选房源接口代码优化

顾绍勇 5 лет назад
Родитель
Сommit
1e761bcb85

+ 13
- 2
src/main/java/com/huiju/estateagents/common/DateUtils.java Просмотреть файл

@@ -30,11 +30,22 @@ public class DateUtils {
30 30
 
31 31
     public static LocalDateTime day2LocalDateime(String day) {
32 32
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
33
-        return LocalDateTime.parse(day + " 00:00:00",df);
33
+        return LocalDateTime.parse(day + " 00:00:00", df);
34 34
     }
35 35
 
36 36
     public static LocalDateTime dayToLocalDateime(String day) {
37 37
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
38
-        return LocalDateTime.parse(day,df);
38
+        return LocalDateTime.parse(day, df);
39
+    }
40
+
41
+    public static boolean checkTimeRange(LocalDateTime start, LocalDateTime end, LocalDateTime dt) {
42
+        if(dt == null){
43
+            dt = LocalDateTime.now();
44
+        }
45
+
46
+        if(dt.isAfter(start) && dt.isBefore(end)){
47
+            return true;
48
+        }
49
+        return false;
39 50
     }
40 51
 }

+ 48
- 39
src/main/java/com/huiju/estateagents/controller/TaHousingResourcesController.java Просмотреть файл

@@ -13,8 +13,8 @@ import javax.servlet.http.HttpServletRequest;
13 13
 
14 14
 /**
15 15
  * <p>
16
-    * 房源表  前端控制器
17
-    * </p>
16
+ * 房源表  前端控制器
17
+ * </p>
18 18
  *
19 19
  * @author jobob
20 20
  * @since 2020-02-10
@@ -31,22 +31,26 @@ public class TaHousingResourcesController extends BaseController {
31 31
 
32 32
     /**
33 33
      * 分页查询列表
34
-     * @param pageNum
34
+     *
35
+     * @param salesBatchId
36
+     * @param buildingId
37
+     * @param pageNumber
35 38
      * @param pageSize
39
+     * @param request
36 40
      * @return
37 41
      */
38
-    @RequestMapping(value="/admin/taHousingResources",method= RequestMethod.GET)
39
-    public ResponseBean taHousingResourcesList(@RequestParam(value = "salesBatchId",required = true) Integer salesBatchId,
40
-                                               @RequestParam(value = "buildingId",required = true) String buildingId,
41
-                                               @RequestParam(value ="pageNumber",defaultValue = "1") Integer pageNumber,
42
-                                               @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
43
-                                               HttpServletRequest request){
42
+    @RequestMapping(value = "/admin/taHousingResources", method = RequestMethod.GET)
43
+    public ResponseBean taHousingResourcesList(@RequestParam(value = "salesBatchId", required = true) Integer salesBatchId,
44
+                                               @RequestParam(value = "buildingId", required = true) String buildingId,
45
+                                               @RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
46
+                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
47
+                                               HttpServletRequest request) {
44 48
         ResponseBean responseBean = new ResponseBean();
45 49
         try {
46
-            responseBean = iTaHousingResourcesService.selectPageList(salesBatchId, buildingId,pageNumber,pageSize,getOrgId(request));
47
-        }catch (Exception e){
50
+            responseBean = iTaHousingResourcesService.selectPageList(salesBatchId, buildingId, pageNumber, pageSize, getOrgId(request));
51
+        } catch (Exception e) {
48 52
             e.printStackTrace();
49
-            logger.error("taHousingResourcesList -=- {}",e.toString());
53
+            logger.error("taHousingResourcesList -=- {}", e.toString());
50 54
             responseBean.addError(e.getMessage());
51 55
         }
52 56
         return responseBean;
@@ -54,21 +58,22 @@ public class TaHousingResourcesController extends BaseController {
54 58
 
55 59
     /**
56 60
      * 保存对象
61
+     *
57 62
      * @param taHousingResources 实体对象
58 63
      * @return
59 64
      */
60
-    @RequestMapping(value="/taHousingResources",method= RequestMethod.POST)
61
-    public ResponseBean taHousingResourcesAdd(@RequestBody TaHousingResources taHousingResources){
65
+    @RequestMapping(value = "/taHousingResources", method = RequestMethod.POST)
66
+    public ResponseBean taHousingResourcesAdd(@RequestBody TaHousingResources taHousingResources) {
62 67
         ResponseBean responseBean = new ResponseBean();
63 68
         try {
64
-            if (iTaHousingResourcesService.save(taHousingResources)){
69
+            if (iTaHousingResourcesService.save(taHousingResources)) {
65 70
                 responseBean.addSuccess(taHousingResources);
66
-            }else {
71
+            } else {
67 72
                 responseBean.addError("fail");
68 73
             }
69
-        }catch (Exception e){
74
+        } catch (Exception e) {
70 75
             e.printStackTrace();
71
-            logger.error("taHousingResourcesAdd -=- {}",e.toString());
76
+            logger.error("taHousingResourcesAdd -=- {}", e.toString());
72 77
             responseBean.addError(e.getMessage());
73 78
         }
74 79
         return responseBean;
@@ -76,21 +81,22 @@ public class TaHousingResourcesController extends BaseController {
76 81
 
77 82
     /**
78 83
      * 根据id删除对象
79
-     * @param id  实体ID
84
+     *
85
+     * @param id 实体ID
80 86
      */
81 87
     @ResponseBody
82
-    @RequestMapping(value="/taHousingResources/{id}", method= RequestMethod.DELETE)
83
-    public ResponseBean taHousingResourcesDelete(@PathVariable Integer id){
88
+    @RequestMapping(value = "/taHousingResources/{id}", method = RequestMethod.DELETE)
89
+    public ResponseBean taHousingResourcesDelete(@PathVariable Integer id) {
84 90
         ResponseBean responseBean = new ResponseBean();
85 91
         try {
86
-            if(iTaHousingResourcesService.removeById(id)){
92
+            if (iTaHousingResourcesService.removeById(id)) {
87 93
                 responseBean.addSuccess("success");
88
-            }else {
94
+            } else {
89 95
                 responseBean.addError("fail");
90 96
             }
91
-        }catch (Exception e){
97
+        } catch (Exception e) {
92 98
             e.printStackTrace();
93
-            logger.error("taHousingResourcesDelete -=- {}",e.toString());
99
+            logger.error("taHousingResourcesDelete -=- {}", e.toString());
94 100
             responseBean.addError(e.getMessage());
95 101
         }
96 102
         return responseBean;
@@ -98,23 +104,24 @@ public class TaHousingResourcesController extends BaseController {
98 104
 
99 105
     /**
100 106
      * 修改对象
101
-     * @param id  实体ID
107
+     *
108
+     * @param id                 实体ID
102 109
      * @param taHousingResources 实体对象
103 110
      * @return
104 111
      */
105
-    @RequestMapping(value="/taHousingResources/{id}",method= RequestMethod.PUT)
112
+    @RequestMapping(value = "/taHousingResources/{id}", method = RequestMethod.PUT)
106 113
     public ResponseBean taHousingResourcesUpdate(@PathVariable Integer id,
107
-                                                 @RequestBody TaHousingResources taHousingResources){
114
+                                                 @RequestBody TaHousingResources taHousingResources) {
108 115
         ResponseBean responseBean = new ResponseBean();
109 116
         try {
110
-            if (iTaHousingResourcesService.updateById(taHousingResources)){
117
+            if (iTaHousingResourcesService.updateById(taHousingResources)) {
111 118
                 responseBean.addSuccess(taHousingResources);
112
-            }else {
119
+            } else {
113 120
                 responseBean.addError("fail");
114 121
             }
115
-        }catch (Exception e){
122
+        } catch (Exception e) {
116 123
             e.printStackTrace();
117
-            logger.error("taHousingResourcesUpdate -=- {}",e.toString());
124
+            logger.error("taHousingResourcesUpdate -=- {}", e.toString());
118 125
             responseBean.addError(e.getMessage());
119 126
         }
120 127
         return responseBean;
@@ -122,16 +129,17 @@ public class TaHousingResourcesController extends BaseController {
122 129
 
123 130
     /**
124 131
      * 根据id查询对象
125
-     * @param id  实体ID
132
+     *
133
+     * @param id 实体ID
126 134
      */
127
-    @RequestMapping(value="/taHousingResources/{id}",method= RequestMethod.GET)
128
-    public ResponseBean taHousingResourcesGet(@PathVariable Integer id){
135
+    @RequestMapping(value = "/taHousingResources/{id}", method = RequestMethod.GET)
136
+    public ResponseBean taHousingResourcesGet(@PathVariable Integer id) {
129 137
         ResponseBean responseBean = new ResponseBean();
130 138
         try {
131 139
             responseBean.addSuccess(iTaHousingResourcesService.getById(id));
132
-        }catch (Exception e){
140
+        } catch (Exception e) {
133 141
             e.printStackTrace();
134
-            logger.error("taHousingResourcesDelete -=- {}",e.toString());
142
+            logger.error("taHousingResourcesDelete -=- {}", e.toString());
135 143
             responseBean.addError(e.getMessage());
136 144
         }
137 145
         return responseBean;
@@ -185,10 +193,11 @@ public class TaHousingResourcesController extends BaseController {
185 193
      * @return
186 194
      */
187 195
     @RequestMapping(value = "/wx/getHousingDetailById", method = RequestMethod.POST)
188
-    public ResponseBean getHousingDetailById(@RequestParam(value = "houseId") String houseId) {
196
+    public ResponseBean getHousingDetailById(@RequestParam(value = "houseId") String houseId,
197
+                                             @RequestParam(value = "personId") String personId) {
189 198
         ResponseBean responseBean = new ResponseBean();
190 199
         try {
191
-            responseBean.addSuccess(iTaHousingResourcesService.getHousingDetailById(houseId));
200
+            responseBean.addSuccess(iTaHousingResourcesService.getHousingDetailById(personId, houseId));
192 201
         } catch (Exception e) {
193 202
             logger.error("getHousingDetailById -=- {}", e);
194 203
             responseBean.addError(e.getMessage());

+ 2
- 13
src/main/java/com/huiju/estateagents/controller/TaPreselectionRecordController.java Просмотреть файл

@@ -82,20 +82,9 @@ public class TaPreselectionRecordController extends BaseController {
82 82
                 return responseBean;
83 83
             }
84 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
-            }
85
+            responseBean = iTaPreselectionRecordService.taPreselectionRecordAdd(taPreselectionRecord);
86
+            logger.info("taPreselectionRecordAdd 返回结果,responseBean:{}", JSONObject.toJSONString(responseBean));
93 87
 
94
-            if (iTaPreselectionRecordService.save(taPreselectionRecord)) {
95
-                responseBean.addSuccess(taPreselectionRecord);
96
-            } else {
97
-                responseBean.addError("fail");
98
-            }
99 88
         } catch (Exception e) {
100 89
             e.printStackTrace();
101 90
             logger.error("taPreselectionRecordAdd -=- {}", e.toString());

+ 5
- 1
src/main/java/com/huiju/estateagents/mapper/TaHousingResourcesMapper.java Просмотреть файл

@@ -49,6 +49,7 @@ public interface TaHousingResourcesMapper extends BaseMapper<TaHousingResources>
49 49
 
50 50
     /**
51 51
      * 增加热度值
52
+     *
52 53
      * @param houseId
53 54
      * @return
54 55
      */
@@ -56,6 +57,7 @@ public interface TaHousingResourcesMapper extends BaseMapper<TaHousingResources>
56 57
 
57 58
     /**
58 59
      * 减少热度值
60
+     *
59 61
      * @param houseId
60 62
      * @return
61 63
      */
@@ -65,7 +67,9 @@ public interface TaHousingResourcesMapper extends BaseMapper<TaHousingResources>
65 67
      * 根据房源ID获取房源详情
66 68
      *
67 69
      * @param houseId
70
+     * @param type    是否只查询已发布数据,1是 0否
68 71
      * @return
69 72
      */
70
-    TaHousingResourcesPO getHousingDetailById(String houseId);
73
+    TaHousingResourcesPO getHousingDetailById(@Param("houseId") String houseId,
74
+                                              @Param("type") String type);
71 75
 }

+ 30
- 0
src/main/java/com/huiju/estateagents/po/TaHousingResourcesPO.java Просмотреть файл

@@ -1,10 +1,13 @@
1 1
 package com.huiju.estateagents.po;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.TableField;
3 4
 import com.huiju.estateagents.entity.TaHousingResources;
4 5
 import lombok.Data;
5 6
 import lombok.EqualsAndHashCode;
6 7
 import lombok.experimental.Accessors;
7 8
 
9
+import java.time.LocalDateTime;
10
+
8 11
 /**
9 12
  * @Auther: gusy
10 13
  * @Date: 2020/2/11 14:26
@@ -13,7 +16,34 @@ import lombok.experimental.Accessors;
13 16
 @EqualsAndHashCode(callSuper = false)
14 17
 @Accessors(chain = true)
15 18
 public class TaHousingResourcesPO extends TaHousingResources {
19
+
20
+    /**
21
+     * 户型名称
22
+     */
23
+    private String apartmentName;
24
+
16 25
     private Double insideArea;
17 26
 
18 27
     private Double buildingArea;
28
+
29
+    /**
30
+     * 是否预选已经预选,1 是 0 否
31
+     */
32
+    @TableField(exist = false)
33
+    private Boolean isPreselect;
34
+
35
+    /**
36
+     * 预选开始时间
37
+     */
38
+    private LocalDateTime preselectionStartTime;
39
+
40
+    /**
41
+     * 预选结束时间
42
+     */
43
+    private LocalDateTime preselectionEndTime;
44
+
45
+    /**
46
+     * 销售批次状态
47
+     */
48
+    private Integer saleBatchStatus;
19 49
 }

+ 2
- 1
src/main/java/com/huiju/estateagents/service/ITaHousingResourcesService.java Просмотреть файл

@@ -53,8 +53,9 @@ public interface ITaHousingResourcesService extends IService<TaHousingResources>
53 53
     /**
54 54
      * 根据房源ID获取房源详情
55 55
      *
56
+     * @param personId
56 57
      * @param houseId
57 58
      * @return
58 59
      */
59
-    TaHousingResourcesPO getHousingDetailById(String houseId);
60
+    TaHousingResourcesPO getHousingDetailById(String personId,String houseId);
60 61
 }

+ 2
- 1
src/main/java/com/huiju/estateagents/service/ITaPreselectionRecordService.java Просмотреть файл

@@ -2,6 +2,7 @@ package com.huiju.estateagents.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.huiju.estateagents.base.ResponseBean;
5 6
 import com.huiju.estateagents.entity.TaPreselectionRecord;
6 7
 import com.huiju.estateagents.po.TaPreselectionRecordPO;
7 8
 
@@ -31,7 +32,7 @@ public interface ITaPreselectionRecordService extends IService<TaPreselectionRec
31 32
      * @param taPreselectionRecord
32 33
      * @return
33 34
      */
34
-    Boolean taPreselectionRecordAdd(TaPreselectionRecord taPreselectionRecord);
35
+    ResponseBean taPreselectionRecordAdd(TaPreselectionRecord taPreselectionRecord);
35 36
 
36 37
     /**
37 38
      * 取消预选

+ 8
- 6
src/main/java/com/huiju/estateagents/service/impl/TaHousingResourcesServiceImpl.java Просмотреть файл

@@ -34,6 +34,7 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
34 34
 
35 35
     @Autowired
36 36
     private TaHousingResourcesMapper taHousingResourcesMapper;
37
+
37 38
     /**
38 39
      * 分页获取房源详情数据
39 40
      *
@@ -50,9 +51,9 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
50 51
         IPage<TaHousingResources> pg = new Page<>(pageNumber, pageSize);
51 52
         QueryWrapper<TaHousingResources> queryWrapper = new QueryWrapper<>();
52 53
         //销售批次id
53
-        queryWrapper.eq("sales_batch_id",salesBatchId);
54
-        queryWrapper.eq("building_id",buildingId);
55
-        queryWrapper.eq("org_id",orgId);
54
+        queryWrapper.eq("sales_batch_id", salesBatchId);
55
+        queryWrapper.eq("building_id", buildingId);
56
+        queryWrapper.eq("org_id", orgId);
56 57
         queryWrapper.eq("status", CommConstant.STATUS_NORMAL);
57 58
         queryWrapper.orderByDesc("create_date");
58 59
         IPage<TaHousingResources> list = this.page(pg, queryWrapper);
@@ -96,13 +97,14 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
96 97
     /**
97 98
      * 根据房源ID获取房源详情
98 99
      *
100
+     * @param personId
99 101
      * @param houseId
100 102
      * @return
101 103
      */
102 104
     @Override
103
-    public TaHousingResourcesPO getHousingDetailById(String houseId) {
104
-        logger.info("getHousingDetailById 接收参数:houseId:{}", houseId);
105
+    public TaHousingResourcesPO getHousingDetailById(String personId, String houseId) {
106
+        logger.info("getHousingDetailById 接收参数:personId:{},houseId:{}", personId, houseId);
105 107
 
106
-        return taHousingResourcesMapper.getHousingDetailById(houseId);
108
+        return taHousingResourcesMapper.getHousingDetailById(houseId, "1");
107 109
     }
108 110
 }

+ 44
- 2
src/main/java/com/huiju/estateagents/service/impl/TaPreselectionRecordServiceImpl.java Просмотреть файл

@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONObject;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.huiju.estateagents.base.ResponseBean;
7 8
 import com.huiju.estateagents.common.DateUtils;
8 9
 import com.huiju.estateagents.entity.TaPreselectionRecord;
9 10
 import com.huiju.estateagents.mapper.TaHousingResourcesMapper;
10 11
 import com.huiju.estateagents.mapper.TaPreselectionRecordMapper;
12
+import com.huiju.estateagents.po.TaHousingResourcesPO;
11 13
 import com.huiju.estateagents.po.TaPreselectionRecordPO;
12 14
 import com.huiju.estateagents.service.ITaPreselectionRecordService;
13 15
 import org.slf4j.Logger;
@@ -47,16 +49,56 @@ public class TaPreselectionRecordServiceImpl extends ServiceImpl<TaPreselectionR
47 49
 
48 50
     @Override
49 51
     @Transactional
50
-    public Boolean taPreselectionRecordAdd(TaPreselectionRecord taPreselectionRecord) {
52
+    public ResponseBean taPreselectionRecordAdd(TaPreselectionRecord taPreselectionRecord) {
51 53
         logger.info("listPreselectionRecord 接收参数:taPreselectionRecord:{}", JSONObject.toJSONString(taPreselectionRecord));
52 54
 
55
+        ResponseBean responseBean = new ResponseBean();
56
+
57
+        // 校验用户是否已经预选房源
58
+        TaPreselectionRecord record = taPreselectionRecordMapper
59
+                .getRecordByPersonIdAndHouseId(taPreselectionRecord.getPersonId(), taPreselectionRecord.getHouseId());
60
+        if (record != null) {
61
+            responseBean.addError("您已经预选过该房源");
62
+            return responseBean;
63
+        }
64
+
65
+        TaHousingResourcesPO resourcesPO = taHousingResourcesMapper.getHousingDetailById(taPreselectionRecord.getHouseId(), "0");
66
+        if (resourcesPO == null) {
67
+            responseBean.addError("fail");
68
+            return responseBean;
69
+        }
70
+
71
+        // 校验当前批次状态是否为已发布
72
+        if (resourcesPO.getSaleBatchStatus() != 1) {
73
+            responseBean.addError("当前销售批次已临时取消发布,请稍后再试或联系置业顾问了解详情。");
74
+            return responseBean;
75
+        }
76
+
77
+        // 校验当前房源状态是否为已发布
78
+        if (!"1".equals(resourcesPO.getStatus())) {
79
+            responseBean.addError("当前房源已临时取消发布,请稍后再试或联系置业顾问了解详情。");
80
+            return responseBean;
81
+        }
82
+
83
+        // 校验预选操作时间是否在规定范围内
84
+        if (DateUtils.checkTimeRange(resourcesPO.getPreselectionStartTime(), resourcesPO.getPreselectionEndTime(), null)) {
85
+            responseBean.addError("当前时间不在预选时间范围内,请联系置业顾问了解详情。");
86
+            return responseBean;
87
+        }
88
+
53 89
         // 添加预选记录
54 90
         taPreselectionRecord.setStatus(1);
55 91
         taPreselectionRecord.setCreateDate(LocalDateTime.now());
56 92
         save(taPreselectionRecord);
57 93
 
58 94
         // 更新房源表热度
59
-        return taHousingResourcesMapper.updateForAddHeat(taPreselectionRecord.getHouseId());
95
+        Boolean result = taHousingResourcesMapper.updateForAddHeat(taPreselectionRecord.getHouseId());
96
+        if (result) {
97
+            responseBean.addSuccess(taPreselectionRecord);
98
+            return responseBean;
99
+        }
100
+        responseBean.addError("fail");
101
+        return responseBean;
60 102
     }
61 103
 
62 104
     @Override

+ 63
- 54
src/main/resources/mapper/TaHousingResourcesMapper.xml Просмотреть файл

@@ -4,40 +4,40 @@
4 4
 
5 5
     <select id="listHousingResources" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
6 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
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 25
         FROM
26
-            ta_housing_resources t,
27
-            ta_building_apartment t2
26
+        ta_housing_resources t,
27
+        ta_building_apartment t2
28 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
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 39
         ORDER BY
40
-            t.create_date DESC
40
+        t.create_date DESC
41 41
     </select>
42 42
 
43 43
     <select id="listBuildApartmentBySalesBatchId" resultType="com.huiju.estateagents.entity.TaBuildingApartment">
@@ -72,32 +72,41 @@
72 72
 
73 73
     <select id="getHousingDetailById" resultType="com.huiju.estateagents.po.TaHousingResourcesPO">
74 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
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.apartment_name,
92
+        t2.inside_area,
93
+        t2.building_area,
94
+        t3.preselection_start_time,
95
+        t3.preselection_end_time,
96
+        t3.`status` saleBatchStatus
93 97
         FROM
94
-            ta_housing_resources t,
95
-            ta_building_apartment t2
98
+        ta_housing_resources t,
99
+        ta_building_apartment t2,
100
+        ta_sales_batch t3
96 101
         WHERE
97
-            t.house_id = #{houseId}
98
-            AND t.apartment_id = t2.apartment_id
102
+        t.house_id = #{houseId}
103
+        AND t.apartment_id = t2.apartment_id
104
+        AND t.sales_batch_id = t3.sales_batch_id
105
+        <if test="type != null and type == '1' ">
99 106
             AND t.`status` = 1
100
-            AND t2.`status` = 1
107
+            AND t3.`status` = 1
108
+        </if>
109
+        AND t2.`status` = 1
101 110
     </select>
102 111
 
103 112
 </mapper>