|
@@ -18,15 +18,13 @@ import com.huiju.estateagents.service.ITaBuildingService;
|
18
|
18
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
19
|
19
|
import com.huiju.estateagents.service.TaPosterService;
|
20
|
20
|
import com.huiju.estateagents.service.TaShareContentService;
|
|
21
|
+import javafx.scene.control.Tab;
|
21
|
22
|
import org.apache.commons.collections.CollectionUtils;
|
22
|
23
|
import org.springframework.beans.factory.annotation.Autowired;
|
23
|
24
|
import org.springframework.stereotype.Service;
|
24
|
25
|
|
25
|
26
|
import java.time.LocalDateTime;
|
26
|
|
-import java.util.ArrayList;
|
27
|
|
-import java.util.HashMap;
|
28
|
|
-import java.util.List;
|
29
|
|
-import java.util.Map;
|
|
27
|
+import java.util.*;
|
30
|
28
|
import java.util.stream.Collectors;
|
31
|
29
|
|
32
|
30
|
/**
|
|
@@ -286,10 +284,17 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
286
|
284
|
|
287
|
285
|
@Override
|
288
|
286
|
public ResponseBean buildingUpdate(String parameter, Integer orgId) {
|
|
287
|
+ ResponseBean responseBean = new ResponseBean();
|
289
|
288
|
JSONObject object= JSONObject.parseObject(parameter);
|
290
|
289
|
|
291
|
290
|
TaBuilding building = object.toJavaObject(TaBuilding.class);
|
292
|
291
|
|
|
292
|
+ boolean isMainMoreThanTenFlag = countIsMainBuilding(building);
|
|
293
|
+ if (!isMainMoreThanTenFlag){
|
|
294
|
+ responseBean.addError("每个城市只能推荐10个楼盘到首页,请先将已推荐楼盘取消推荐后再推荐当前楼盘。");
|
|
295
|
+ return responseBean;
|
|
296
|
+ }
|
|
297
|
+
|
293
|
298
|
// 先删除视频
|
294
|
299
|
UpdateWrapper<TaBuilding> updateWrapper = new UpdateWrapper<>();
|
295
|
300
|
updateWrapper.eq("building_id", building.getBuildingId());
|
|
@@ -382,6 +387,8 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
382
|
387
|
|
383
|
388
|
@Override
|
384
|
389
|
public ResponseBean buildingAdd(String parameter, Integer orgId) {
|
|
390
|
+ ResponseBean responseBean = new ResponseBean();
|
|
391
|
+
|
385
|
392
|
JSONObject object= JSONObject.parseObject(parameter);
|
386
|
393
|
// 根据orgId查询当前楼盘最大数
|
387
|
394
|
TaOrg taOrg = taOrgMapper.selectById(orgId);
|
|
@@ -395,6 +402,13 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
395
|
402
|
}
|
396
|
403
|
|
397
|
404
|
TaBuilding building = object.toJavaObject(TaBuilding.class);
|
|
405
|
+
|
|
406
|
+ boolean isMainMoreThanTenFlag = countIsMainBuilding(building);
|
|
407
|
+ if (!isMainMoreThanTenFlag){
|
|
408
|
+ responseBean.addError("每个城市只能推荐10个楼盘到首页,请先将已推荐楼盘取消推荐后再推荐当前楼盘。");
|
|
409
|
+ return responseBean;
|
|
410
|
+ }
|
|
411
|
+
|
398
|
412
|
if(null!= object.getDate("openingDate")){
|
399
|
413
|
building.setOpeningDate(DateUtils.date2LocalDateTime(object.getDate("openingDate")));
|
400
|
414
|
}
|
|
@@ -818,6 +832,29 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
818
|
832
|
return taBuildingMapper.countNumByHeavy(heavy, dynamicId);
|
819
|
833
|
}
|
820
|
834
|
|
|
835
|
+ /**
|
|
836
|
+ * 推荐到首页楼盘不能超过10个
|
|
837
|
+ * @param taBuilding
|
|
838
|
+ * @return
|
|
839
|
+ */
|
|
840
|
+ public boolean countIsMainBuilding(TaBuilding taBuilding) {
|
|
841
|
+ if (taBuilding.getIsMain() != 1){
|
|
842
|
+ return true;
|
|
843
|
+ }
|
|
844
|
+ QueryWrapper<TaBuilding> taBuildingQueryWrapper = new QueryWrapper<>();
|
|
845
|
+ taBuildingQueryWrapper.eq("city_id", taBuilding.getCityId());
|
|
846
|
+ taBuildingQueryWrapper.eq("is_main", 1);
|
|
847
|
+ taBuildingQueryWrapper.eq("status", 1);
|
|
848
|
+ if (taBuilding.getBuildingId() != null){
|
|
849
|
+ taBuildingQueryWrapper.ne("building_id", taBuilding.getBuildingId());
|
|
850
|
+ }
|
|
851
|
+ List<TaBuilding> taBuildings = taBuildingMapper.selectList(taBuildingQueryWrapper);
|
|
852
|
+ if (taBuildings != null && taBuildings.size() > 10){
|
|
853
|
+ return false;
|
|
854
|
+ }
|
|
855
|
+ return true;
|
|
856
|
+ }
|
|
857
|
+
|
821
|
858
|
|
822
|
859
|
private List<TaBuildingImg> insertImgBatch(List<TaBuildingImg> imgs, String buildingId) {
|
823
|
860
|
return imgs.stream().map(img -> {
|