|
@@ -13,11 +13,15 @@ import com.huiju.estateagents.mapper.HelpInitiateRecordMapper;
|
13
|
13
|
import com.huiju.estateagents.mapper.HelpRecordMapper;
|
14
|
14
|
import com.huiju.estateagents.service.IHelpRecordService;
|
15
|
15
|
import org.apache.commons.collections.CollectionUtils;
|
|
16
|
+import org.apache.commons.collections.map.HashedMap;
|
16
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
18
|
import org.springframework.stereotype.Service;
|
|
19
|
+import org.springframework.transaction.annotation.Transactional;
|
18
|
20
|
|
19
|
21
|
import java.time.LocalDateTime;
|
|
22
|
+import java.util.HashMap;
|
20
|
23
|
import java.util.List;
|
|
24
|
+import java.util.Map;
|
21
|
25
|
|
22
|
26
|
/**
|
23
|
27
|
* <p>
|
|
@@ -28,6 +32,7 @@ import java.util.List;
|
28
|
32
|
* @since 2019-10-17
|
29
|
33
|
*/
|
30
|
34
|
@Service
|
|
35
|
+@Transactional(rollbackFor = Exception.class)
|
31
|
36
|
public class HelpRecordServiceImpl extends ServiceImpl<HelpRecordMapper, HelpRecord> implements IHelpRecordService {
|
32
|
37
|
|
33
|
38
|
@Autowired
|
|
@@ -57,7 +62,7 @@ public class HelpRecordServiceImpl extends ServiceImpl<HelpRecordMapper, HelpRec
|
57
|
62
|
|
58
|
63
|
HelpActivity helpActivity = helpActivityMapper.selectById(helpRecord.getHelpActivityId());
|
59
|
64
|
//是否助力成功
|
60
|
|
- if (helpActivity.getEnlistNum() >= helpActivity.getPersonNum()){
|
|
65
|
+ if (null != helpActivity.getEnlistNum() && helpActivity.getEnlistNum() >= helpActivity.getPersonNum()){
|
61
|
66
|
return ResponseBean.error("已经助力成功", ResponseBean.ERROR_UNAVAILABLE);
|
62
|
67
|
}
|
63
|
68
|
if (helpActivity.getEndDate().isBefore(LocalDateTime.now())){
|
|
@@ -69,8 +74,8 @@ public class HelpRecordServiceImpl extends ServiceImpl<HelpRecordMapper, HelpRec
|
69
|
74
|
QueryWrapper<HelpRecord> queryWrapper = new QueryWrapper<>();
|
70
|
75
|
queryWrapper.eq("org_id",orgId);
|
71
|
76
|
queryWrapper.eq("help_activity_id",helpRecord.getHelpActivityId());
|
72
|
|
- queryWrapper.eq("persion_id",person.getPersonId());
|
73
|
|
- if (null != helpNum && helpNum >= 0){
|
|
77
|
+ queryWrapper.eq("person_id",person.getPersonId());
|
|
78
|
+ if (null != helpNum && helpNum > 0){
|
74
|
79
|
//查看这个人是否助力过,和助力了几次
|
75
|
80
|
List<HelpRecord> helpRecords = helpRecordMapper.selectList(queryWrapper);
|
76
|
81
|
if (helpRecords.size() >= helpNum){
|
|
@@ -84,6 +89,9 @@ public class HelpRecordServiceImpl extends ServiceImpl<HelpRecordMapper, HelpRec
|
84
|
89
|
return ResponseBean.error("您已经助力过了,无需重复助力", ResponseBean.ERROR_UNAVAILABLE);
|
85
|
90
|
}
|
86
|
91
|
//反更新在入库
|
|
92
|
+ if (null == helpActivity.getEnlistNum()){
|
|
93
|
+ helpActivity.setEnlistNum(0);
|
|
94
|
+ }
|
87
|
95
|
helpActivity.setEnlistNum(helpActivity.getEnlistNum()+1);
|
88
|
96
|
helpActivityMapper.updateById(helpActivity);
|
89
|
97
|
//插入数据
|
|
@@ -99,9 +107,15 @@ public class HelpRecordServiceImpl extends ServiceImpl<HelpRecordMapper, HelpRec
|
99
|
107
|
helpInitiateRecord.setSucceedDate(LocalDateTime.now());
|
100
|
108
|
helpInitiateRecord.setStatus(0);
|
101
|
109
|
}
|
|
110
|
+ if (null == helpInitiateRecord.getEnlistNum()){
|
|
111
|
+ helpInitiateRecord.setEnlistNum(0);
|
|
112
|
+ }
|
102
|
113
|
helpInitiateRecord.setEnlistNum(helpInitiateRecord.getEnlistNum()+1);
|
103
|
114
|
helpInitiateRecordMapper.updateById(helpInitiateRecord);
|
104
|
|
- return ResponseBean.success(helpInitiateRecord);
|
|
115
|
+ Map<String,Object> map = new HashMap<>();
|
|
116
|
+ map.put("helpRecord",helpRecord);
|
|
117
|
+ map.put("helpInitiateRecord",helpInitiateRecord);
|
|
118
|
+ return ResponseBean.success(map);
|
105
|
119
|
}
|
106
|
120
|
|
107
|
121
|
}
|