1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.tanpu.fund.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.fund.entity.generator.ReportDownloadSummary;
import com.tanpu.fund.mapper.generator.ReportDownloadSummaryMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Service
public class DownloadPdfService {
@Resource
private ReportDownloadSummaryMapper reportDownloadSummaryMapper;
private static final Integer onceAddTimes = 200;
@Transactional(rollbackFor = Exception.class)
public void emptyStandardVipCount(String userId) {
LambdaQueryWrapper<ReportDownloadSummary> qw = new LambdaQueryWrapper<>();
List<ReportDownloadSummary> reportDownloadSummaries = reportDownloadSummaryMapper.selectList(qw.eq(ReportDownloadSummary::getUserId, userId));
if (CollectionUtils.isEmpty(reportDownloadSummaries)){
ReportDownloadSummary entity = ReportDownloadSummary.builder().userId(userId).stdVipLimit(0).build();
reportDownloadSummaryMapper.insert(entity);
}else {
ReportDownloadSummary entity = reportDownloadSummaries.get(0);
entity.setStdVipLimit(0);
entity.setDeepReportStd(0);
entity.setHoldFundReportStd(0);
entity.setCumulativeProfitReportStd(0);
reportDownloadSummaryMapper.updateById(entity);
}
}
@Transactional(rollbackFor = Exception.class)
public void addStandardVipCount(String userId) {
LambdaQueryWrapper<ReportDownloadSummary> qw = new LambdaQueryWrapper<>();
List<ReportDownloadSummary> reportDownloadSummaries = reportDownloadSummaryMapper.selectList(qw.eq(ReportDownloadSummary::getUserId, userId));
if (CollectionUtils.isEmpty(reportDownloadSummaries)){
ReportDownloadSummary entity = ReportDownloadSummary.builder().userId(userId).stdVipLimit(onceAddTimes).build();
reportDownloadSummaryMapper.insert(entity);
}else {
ReportDownloadSummary entity = reportDownloadSummaries.get(0);
entity.setStdVipLimit(entity.getStdVipLimit() + onceAddTimes);
reportDownloadSummaryMapper.updateById(entity);
}
}
}