|
@@ -4,13 +4,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
4
|
4
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
6
|
6
|
import com.huiju.estateagents.base.ResponseBean;
|
|
7
|
+import com.huiju.estateagents.common.DateUtils;
|
7
|
8
|
import com.huiju.estateagents.entity.TaSalesBatch;
|
8
|
9
|
import com.huiju.estateagents.mapper.TaSalesBatchMapper;
|
9
|
10
|
import com.huiju.estateagents.service.ITaSalesBatchService;
|
|
11
|
+import org.slf4j.Logger;
|
|
12
|
+import org.slf4j.LoggerFactory;
|
10
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
11
|
14
|
import org.springframework.stereotype.Service;
|
12
|
15
|
|
|
16
|
+import java.time.LocalDateTime;
|
|
17
|
+import java.util.ArrayList;
|
|
18
|
+import java.util.Date;
|
13
|
19
|
import java.util.List;
|
|
20
|
+import java.util.Map;
|
14
|
21
|
|
15
|
22
|
/**
|
16
|
23
|
* <p>
|
|
@@ -23,6 +30,8 @@ import java.util.List;
|
23
|
30
|
@Service
|
24
|
31
|
public class TaSalesBatchServiceImpl extends ServiceImpl<TaSalesBatchMapper, TaSalesBatch> implements ITaSalesBatchService {
|
25
|
32
|
|
|
33
|
+ private Logger logger = LoggerFactory.getLogger(TaSalesBatchServiceImpl.class);
|
|
34
|
+
|
26
|
35
|
@Autowired
|
27
|
36
|
private TaSalesBatchMapper taSalesBatchMapper;
|
28
|
37
|
|
|
@@ -35,11 +44,64 @@ public class TaSalesBatchServiceImpl extends ServiceImpl<TaSalesBatchMapper, TaS
|
35
|
44
|
public ResponseBean delSalesBatchList(Integer orgId, List<TaSalesBatch> taSalesBatchList) {
|
36
|
45
|
ResponseBean responseBean = new ResponseBean();
|
37
|
46
|
Integer count = taSalesBatchMapper.countPreSelectRecord(orgId, taSalesBatchList);
|
38
|
|
- if (count > 0){
|
|
47
|
+ if (count > 0) {
|
39
|
48
|
responseBean.addError("已有用户预选,请先删除预选记录。");
|
40
|
49
|
return responseBean;
|
41
|
50
|
}
|
42
|
51
|
taSalesBatchMapper.updateSalesBatchStatus(orgId, taSalesBatchList);
|
43
|
52
|
return responseBean;
|
44
|
53
|
}
|
|
54
|
+
|
|
55
|
+ /**
|
|
56
|
+ * 获取通知信息
|
|
57
|
+ *
|
|
58
|
+ * @param salesBatchId 销售批次ID
|
|
59
|
+ * @return
|
|
60
|
+ */
|
|
61
|
+ @Override
|
|
62
|
+ public ResponseBean getNoticeInfo(Integer salesBatchId) {
|
|
63
|
+ logger.info("getNoticeInfo 接收参数:saleBatchId:{}", salesBatchId);
|
|
64
|
+
|
|
65
|
+ ResponseBean responseBean = new ResponseBean();
|
|
66
|
+
|
|
67
|
+ TaSalesBatch salesBatch = getById(salesBatchId);
|
|
68
|
+ if (salesBatch == null) {
|
|
69
|
+ responseBean.addError("未查询到数据");
|
|
70
|
+ return responseBean;
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ List<String> noticeList = new ArrayList<>();
|
|
74
|
+ // 当前时间万余预选结束时间
|
|
75
|
+ if (DateUtils.isAfter(salesBatch.getPreselectionEndTime())) {
|
|
76
|
+ noticeList.add("预选已结束,请关注下轮预选");
|
|
77
|
+ responseBean.addSuccess(noticeList);
|
|
78
|
+ return responseBean;
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ // 当前时间早于预选开始时间
|
|
82
|
+ if (DateUtils.isBefore(salesBatch.getPreselectionStartTime())) {
|
|
83
|
+ String str = DateUtils.diffTime(DateUtils.timeToLocalDateTime(salesBatch.getPreselectionStartTime()), LocalDateTime.now());
|
|
84
|
+ noticeList.add("距离预选开始还有" + str);
|
|
85
|
+ responseBean.addSuccess(noticeList);
|
|
86
|
+ return responseBean;
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ // 当前时间在预选时间内
|
|
90
|
+ if (DateUtils.isAfter(salesBatch.getPreselectionStartTime()) && DateUtils.isBefore(salesBatch.getPreselectionEndTime())) {
|
|
91
|
+ String str = DateUtils.diffTime(LocalDateTime.now(), DateUtils.timeToLocalDateTime(salesBatch.getPreselectionEndTime()));
|
|
92
|
+ noticeList.add("距离预选结束还有" + str);
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ // 获取房源预选数量
|
|
96
|
+ Map<String, Long> result = taSalesBatchMapper.getTotalHousesAndHeat(salesBatchId);
|
|
97
|
+ if (result != null) {
|
|
98
|
+ Long totalHouses = result.get("totalHouses");
|
|
99
|
+ Long totalRealHeat = result.get("totalRealHeat");
|
|
100
|
+ if (totalRealHeat != null && totalRealHeat > 0) {
|
|
101
|
+ noticeList.add("当前" + totalHouses + "套房源已有" + totalRealHeat + "人成功预选 ");
|
|
102
|
+ }
|
|
103
|
+ }
|
|
104
|
+ responseBean.addSuccess(noticeList);
|
|
105
|
+ return responseBean;
|
|
106
|
+ }
|
45
|
107
|
}
|