|
@@ -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.entity.HelpActivity;
|
|
9
|
+import com.huiju.estateagents.entity.HelpInitiateRecord;
|
|
10
|
+import com.huiju.estateagents.entity.HelpRecord;
|
9
|
11
|
import com.huiju.estateagents.mapper.HelpActivityMapper;
|
|
12
|
+import com.huiju.estateagents.mapper.HelpInitiateRecordMapper;
|
|
13
|
+import com.huiju.estateagents.mapper.HelpRecordMapper;
|
10
|
14
|
import com.huiju.estateagents.service.IHelpActivityService;
|
11
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
16
|
import org.springframework.stereotype.Service;
|
13
|
17
|
|
14
|
18
|
import javax.xml.crypto.Data;
|
15
|
19
|
import java.time.LocalDateTime;
|
|
20
|
+import java.util.HashMap;
|
|
21
|
+import java.util.List;
|
16
|
22
|
|
17
|
23
|
/**
|
18
|
24
|
* <p>
|
|
@@ -27,17 +33,24 @@ public class HelpActivityServiceImpl extends ServiceImpl<HelpActivityMapper, Hel
|
27
|
33
|
|
28
|
34
|
@Autowired
|
29
|
35
|
HelpActivityMapper taHelpActivityMapper;
|
|
36
|
+
|
|
37
|
+ @Autowired
|
|
38
|
+ HelpInitiateRecordMapper helpInitiateRecordMapper;
|
|
39
|
+
|
|
40
|
+ @Autowired
|
|
41
|
+ HelpRecordMapper helpRecordMapper;
|
|
42
|
+
|
30
|
43
|
@Override
|
31
|
44
|
public ResponseBean helpActivityList(Integer pageNum, Integer pageSize, Integer cityId, String buildingId, String title, Data startDate, Data endDate, Integer status, Integer orgId) {
|
32
|
45
|
ResponseBean responseBean = new ResponseBean<>();
|
33
|
46
|
IPage<HelpActivity> pg = new Page<>(pageNum, pageSize);
|
34
|
|
- IPage<HelpActivity> result = taHelpActivityMapper.helpActivityListPage(pg,cityId,buildingId,title,startDate,endDate,status,orgId);
|
|
47
|
+ IPage<HelpActivity> result = taHelpActivityMapper.helpActivityListPage(pg, cityId, buildingId, title, startDate, endDate, status, orgId);
|
35
|
48
|
responseBean.addSuccess(result);
|
36
|
49
|
return responseBean;
|
37
|
50
|
}
|
38
|
51
|
|
39
|
52
|
@Override
|
40
|
|
- public void helpActivityAdd(HelpActivity helpActivity,Integer orgId) {
|
|
53
|
+ public void helpActivityAdd(HelpActivity helpActivity, Integer orgId) {
|
41
|
54
|
helpActivity.setOrgId(orgId)
|
42
|
55
|
.setCreateDate(LocalDateTime.now());
|
43
|
56
|
taHelpActivityMapper.insert(helpActivity);
|
|
@@ -47,4 +60,64 @@ public class HelpActivityServiceImpl extends ServiceImpl<HelpActivityMapper, Hel
|
47
|
60
|
public void helpActivityUpdate(HelpActivity helpActivity) {
|
48
|
61
|
taHelpActivityMapper.updateById(helpActivity);
|
49
|
62
|
}
|
50
|
|
-}
|
|
63
|
+
|
|
64
|
+ @Override
|
|
65
|
+ public ResponseBean helpRecord(Integer helpActivityId, int status,Integer pageNum,Integer pageSize) {
|
|
66
|
+ ResponseBean responseBean = new ResponseBean<>();
|
|
67
|
+ // status 0助力成功,1进行中,2助力失败
|
|
68
|
+
|
|
69
|
+ //查询当前助力成功所需的人数限制(persion_num)
|
|
70
|
+ HelpActivity helpActivity = taHelpActivityMapper.selectById(helpActivityId);
|
|
71
|
+ // 得到活动限制助力的总数
|
|
72
|
+ int persionNumCount = helpActivity.getPersionNum();
|
|
73
|
+ IPage<HelpInitiateRecord> pg = new Page<>(pageNum, pageSize);
|
|
74
|
+ QueryWrapper<HelpInitiateRecord> helpInitiateRecordQuery = new QueryWrapper<>();
|
|
75
|
+ helpInitiateRecordQuery.eq("help_activity_id", helpActivityId);
|
|
76
|
+ IPage<HelpInitiateRecord> list = helpInitiateRecordMapper.selectPage(pg,helpInitiateRecordQuery);
|
|
77
|
+
|
|
78
|
+ List<HelpInitiateRecord> helpInitiateRecordList= list.getRecords();
|
|
79
|
+ for (HelpInitiateRecord helpInitiateRecord : helpInitiateRecordList) {
|
|
80
|
+
|
|
81
|
+ // 统计助力成功的总数(发起人得到助力数满了即可)
|
|
82
|
+ QueryWrapper<HelpRecord> helpRecorddQueryWrapper = new QueryWrapper<>();
|
|
83
|
+ helpRecorddQueryWrapper.eq("help_record_initiate_id", helpInitiateRecord.getHelpActivityId());
|
|
84
|
+ // 拿到每个发起人,得到助力的总数
|
|
85
|
+ int helpRecordCount = helpRecordMapper.selectCount(helpRecorddQueryWrapper);
|
|
86
|
+ // 助力成功
|
|
87
|
+ if (0 == status) {
|
|
88
|
+ if (persionNumCount == helpRecordCount) {
|
|
89
|
+ helpInitiateRecord.setHelpCount(helpRecordCount);
|
|
90
|
+ }
|
|
91
|
+ }
|
|
92
|
+ // 助力进行中(活动进行中,未结束)
|
|
93
|
+ if (1 == status && "1".equals(helpActivity.getStatus())) {
|
|
94
|
+ if (persionNumCount > helpRecordCount) {
|
|
95
|
+ helpInitiateRecord.setHelpCount(helpRecordCount);
|
|
96
|
+ }
|
|
97
|
+ }
|
|
98
|
+ // 活动助力失败
|
|
99
|
+ // 活动进行中(活动已结束)
|
|
100
|
+ if (2 == status && "2".equals(helpActivity.getStatus())) {
|
|
101
|
+ if (persionNumCount > helpRecordCount) {
|
|
102
|
+ helpInitiateRecord.setHelpCount(helpRecordCount);
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ }
|
|
106
|
+ }
|
|
107
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
108
|
+ map.put("list", helpInitiateRecordList);
|
|
109
|
+ map.put("total", list.getTotal());
|
|
110
|
+ map.put("pageNum", list.getCurrent());
|
|
111
|
+ map.put("pageSize", list.getSize());
|
|
112
|
+ return ResponseBean.success(map);
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ @Override
|
|
116
|
+ public ResponseBean taHelpRecordDetails(Integer helpRecordInitiateId, Integer pageNum, Integer pageSize) {
|
|
117
|
+ ResponseBean responseBean = new ResponseBean<>();
|
|
118
|
+ IPage<HelpInitiateRecord> pg = new Page<>(pageNum, pageSize);
|
|
119
|
+ IPage<HelpRecord> helpRecordList= helpRecordMapper.taHelpRecordDetails(pg,helpRecordInitiateId);
|
|
120
|
+ responseBean.addSuccess(helpRecordList);
|
|
121
|
+ return responseBean;
|
|
122
|
+ }
|
|
123
|
+}
|