|
@@ -3,14 +3,22 @@ package com.yunzhi.marketing.xlk.service.impl;
|
3
|
3
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
4
|
4
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
5
|
5
|
import com.yunzhi.marketing.base.ResponseBean;
|
|
6
|
+import com.yunzhi.marketing.common.StringUtils;
|
|
7
|
+import com.yunzhi.marketing.entity.TaBuilding;
|
6
|
8
|
import com.yunzhi.marketing.entity.TaCheckin;
|
|
9
|
+import com.yunzhi.marketing.entity.TdCity;
|
|
10
|
+import com.yunzhi.marketing.mapper.TdCityMapper;
|
|
11
|
+import com.yunzhi.marketing.xlk.dto.SearchHouseDTO;
|
7
|
12
|
import com.yunzhi.marketing.xlk.entity.SearchHouse;
|
8
|
13
|
import com.yunzhi.marketing.xlk.mapper.SearchHouseMapper;
|
9
|
14
|
import com.yunzhi.marketing.xlk.service.ISearchHouseService;
|
10
|
15
|
import com.yunzhi.marketing.xlk.vo.SearchHouseVO;
|
|
16
|
+import io.swagger.models.auth.In;
|
11
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
18
|
import org.springframework.stereotype.Service;
|
13
|
19
|
|
|
20
|
+import java.util.List;
|
|
21
|
+
|
14
|
22
|
/**
|
15
|
23
|
* <p>
|
16
|
24
|
* 帮我找房 服务实现类
|
|
@@ -25,6 +33,9 @@ public class SearchHouseServiceImpl extends ServiceImpl<SearchHouseMapper, Searc
|
25
|
33
|
@Autowired
|
26
|
34
|
private SearchHouseMapper searchHouseMapper;
|
27
|
35
|
|
|
36
|
+ @Autowired
|
|
37
|
+ private TdCityMapper tdCityMapper;
|
|
38
|
+
|
28
|
39
|
/**
|
29
|
40
|
* 查询我的找房需求列表
|
30
|
41
|
*
|
|
@@ -43,4 +54,103 @@ public class SearchHouseServiceImpl extends ServiceImpl<SearchHouseMapper, Searc
|
43
|
54
|
public SearchHouseVO selectSearchHouseDetail(String id) {
|
44
|
55
|
return searchHouseMapper.selectSearchHouseDetail(id);
|
45
|
56
|
}
|
|
57
|
+
|
|
58
|
+ /**
|
|
59
|
+ * 推荐逻辑如下
|
|
60
|
+ * 1、先判断区域+价格,如果有符合楼盘,则推荐,如无看2;
|
|
61
|
+ * 2、判断城市+价格,如过有符合楼盘,则推荐,如无看3;
|
|
62
|
+ * 3、如选择了“不限城市”,则判断价格,在当前城市内推荐一个符合的。
|
|
63
|
+ * @param searchHouseDTO
|
|
64
|
+ * @return
|
|
65
|
+ */
|
|
66
|
+ @Override
|
|
67
|
+ public List<TaBuilding> getRecommendBuildings(Integer orgId, SearchHouseDTO searchHouseDTO) {
|
|
68
|
+ // 区域
|
|
69
|
+ String area = searchHouseDTO.getIntentArea();
|
|
70
|
+ Integer areaId = StringUtils.isEmpty(area) ? null : Integer.valueOf(area);
|
|
71
|
+ // 区域所属城市
|
|
72
|
+ Integer areaCity = null;
|
|
73
|
+ if (null != areaId) {
|
|
74
|
+ TdCity city = tdCityMapper.selectById(areaId);
|
|
75
|
+ areaCity = city.getParentid();
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+ // 当前城市
|
|
79
|
+ Integer cityId = searchHouseDTO.getCityId();
|
|
80
|
+ // 最小总价
|
|
81
|
+ Integer minPriceW = Integer.parseInt(searchHouseDTO.getMinPrice());
|
|
82
|
+ // 最大总价
|
|
83
|
+ Integer maxPriceW = Integer.parseInt(searchHouseDTO.getMaxPrice());
|
|
84
|
+ // 面积字典
|
|
85
|
+ Integer areaResultId = searchHouseDTO.getAreaResultId();
|
|
86
|
+ //
|
|
87
|
+ Integer[] unitPrice = getUnitPriceRange(minPriceW, maxPriceW, areaResultId);
|
|
88
|
+ // 最小单价
|
|
89
|
+ Integer minPrice = unitPrice[0];
|
|
90
|
+ // 最大单价
|
|
91
|
+ Integer maxPrice = unitPrice[1];
|
|
92
|
+
|
|
93
|
+ if (null != areaId) {
|
|
94
|
+ // 1、先判断区域+价格
|
|
95
|
+ List<TaBuilding> lst1 = searchHouseMapper.getRecommendBuildings(orgId, null, areaId, minPriceW, maxPriceW, minPrice, maxPrice);
|
|
96
|
+ if (null != lst1 && lst1.size() > 0) {
|
|
97
|
+ return lst1;
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ // 2、判断城市+价格
|
|
101
|
+ List<TaBuilding> lst2 = searchHouseMapper.getRecommendBuildings(orgId, areaCity, null, minPriceW, maxPriceW, minPrice, maxPrice);
|
|
102
|
+ if (null != lst2 && lst2.size() > 0) {
|
|
103
|
+ return lst2;
|
|
104
|
+ }
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+ // 3、当前城市
|
|
108
|
+ return searchHouseMapper.getRecommendBuildings(orgId, cityId, null, minPriceW, maxPriceW, minPrice, maxPrice);
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+ private Integer[] getUnitPriceRange(Integer minPriceW, Integer maxPriceW, Integer areaResultId) {
|
|
112
|
+ Integer minPrice = minPriceW * 10000;
|
|
113
|
+ Integer maxPrice = maxPriceW * 10000;
|
|
114
|
+
|
|
115
|
+ // 字典过滤 - 必须与小程序端保持一致
|
|
116
|
+ switch (areaResultId) {
|
|
117
|
+ case 1:
|
|
118
|
+ // 60㎡ 以下, 则按照 30 - 60 处理
|
|
119
|
+ minPrice = minPrice / 60;
|
|
120
|
+ maxPrice = maxPrice / 30;
|
|
121
|
+ break;
|
|
122
|
+ case 2:
|
|
123
|
+ // 60 - 90
|
|
124
|
+ minPrice = minPrice / 90;
|
|
125
|
+ maxPrice = maxPrice / 60;
|
|
126
|
+ break;
|
|
127
|
+ case 3:
|
|
128
|
+ // 90 - 110
|
|
129
|
+ minPrice = minPrice / 110;
|
|
130
|
+ maxPrice = maxPrice / 90;
|
|
131
|
+ break;
|
|
132
|
+ case 4:
|
|
133
|
+ // 110 - 130
|
|
134
|
+ minPrice = minPrice / 130;
|
|
135
|
+ maxPrice = maxPrice / 110;
|
|
136
|
+ break;
|
|
137
|
+ case 5:
|
|
138
|
+ // 130 - 150
|
|
139
|
+ minPrice = minPrice / 150;
|
|
140
|
+ maxPrice = maxPrice / 130;
|
|
141
|
+ break;
|
|
142
|
+ case 6:
|
|
143
|
+ // 150 - 200
|
|
144
|
+ minPrice = minPrice / 200;
|
|
145
|
+ maxPrice = maxPrice / 150;
|
|
146
|
+ break;
|
|
147
|
+ default:
|
|
148
|
+ // 200 以上
|
|
149
|
+ minPrice = minPrice / 200;
|
|
150
|
+ maxPrice = maxPrice / 200;
|
|
151
|
+ break;
|
|
152
|
+ }
|
|
153
|
+
|
|
154
|
+ return new Integer[] {minPrice, maxPrice};
|
|
155
|
+ }
|
46
|
156
|
}
|