doum
2025-12-12 89029e9ade03f3139c6afcd6bac48d9a668875f3
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.doumee.service.business.impl;
 
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.model.Signup;
import com.doumee.dao.web.dto.coffeebean.CoffeeBeanMemberDTO;
import com.doumee.dao.web.dto.coffeebean.CoffeeBeanTaskDTO;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.service.business.*;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
 
@Service
public class CoffeeBeanTaskServiceImpl implements CoffeeBeanTaskService {
 
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
 
    @Autowired
    private SignupService signupService;
 
    @Autowired
    private SharesService sharesService;
 
    @Autowired
    private CommentService commentService;
 
    @Autowired
    private ShopCommentService shopCommentService;
 
    @Autowired
    private IntegralService integralService;
 
    @Autowired
    private MemberService memberService;
 
 
    @Override
    public List<CoffeeBeanTaskDTO> getTask() {
 
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
 
        List<SystemDictData> systemDictData = systemDictDataBiz.queryListByCode(Constants.COFFEE_BEAN_TASK, null);
        List<CoffeeBeanTaskDTO> list = new ArrayList<>();
        for (SystemDictData dictData : systemDictData){
 
            if (Constants.SIGN_BOARD.equalsIgnoreCase(dictData.getLabel())){
                Signup wrapper = new Signup();
                wrapper.setMemberId(loginUserInfo.getMemberId());
                Signup one = signupService.findOne(wrapper);
                LocalDate dateTime = DateUtil.toDateLocalDateTime(one.getCreateDate()).toLocalDate();
                CoffeeBeanTaskDTO dto = new CoffeeBeanTaskDTO();
                dto.setCode(dictData.getCode());
                dto.setDoneCount(LocalDate.now().compareTo(dateTime) > 0 ? 1 : 0);
                dto.setLabel(dictData.getLabel());
                list.add(dto);
            }
            if (Constants.SHARE_INFO.equalsIgnoreCase(dictData.getLabel())){
 
                Date startDate = DateUtil.toDate(DateUtil.getMonday());
                Date endDate = DateUtil.toDate(DateUtil.getSunday());
                long count = sharesService.count(startDate, endDate, loginUserInfo.getMemberId(), Arrays.asList(0,1,2,3,4));
                CoffeeBeanTaskDTO dto = new CoffeeBeanTaskDTO();
                dto.setCode(dictData.getCode());
                dto.setDoneCount(count);
                dto.setLabel(dictData.getLabel());
                list.add(dto);
 
            }
            if (Constants.SHARE_INVITE_BILL.equalsIgnoreCase(dictData.getLabel())){
 
                Date startDate = DateUtil.toDate(DateUtil.getMonday());
                Date endDate = DateUtil.toDate(DateUtil.getSunday());
                long count = sharesService.count(startDate, endDate, loginUserInfo.getMemberId(),Arrays.asList(5));
                CoffeeBeanTaskDTO dto = new CoffeeBeanTaskDTO();
                dto.setCode(dictData.getCode());
                dto.setDoneCount(count);
                dto.setLabel(dictData.getLabel());
                list.add(dto);
            }
            if (Constants.INVITE_USER_LOGIN.equalsIgnoreCase(dictData.getLabel())){
                CoffeeBeanTaskDTO dto = new CoffeeBeanTaskDTO();
                dto.setCode(dictData.getCode());
                dto.setLabel(dictData.getLabel());
                list.add(dto);
            }
            if (Constants.POST_COMMENTS.equalsIgnoreCase(dictData.getLabel())){
 
                Date startDate = DateUtil.toDate(DateUtil.getMonday());
                Date endDate = DateUtil.toDate(DateUtil.getSunday());
                long count = commentService.count(startDate, endDate, loginUserInfo.getMemberId());
                long shopcount = shopCommentService.count(startDate, endDate, loginUserInfo.getMemberId(),null);
                CoffeeBeanTaskDTO dto = new CoffeeBeanTaskDTO();
                dto.setCode(dictData.getCode());
                dto.setDoneCount(count+shopcount);
                dto.setLabel(dictData.getLabel());
                list.add(dto);
            }
            if (Constants.COFFEE_MAP_CONSUME.equalsIgnoreCase(dictData.getLabel())){
                CoffeeBeanTaskDTO dto = new CoffeeBeanTaskDTO();
                dto.setCode(dictData.getCode());
                dto.setLabel(dictData.getLabel());
                list.add(dto);
            }
        }
        return list;
    }
 
    @Override
    public CoffeeBeanMemberDTO getCoffeeBeanMemberDTO() {
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
 
        Member member = memberService.findById(loginUserInfo.getMemberId());
        Member wrapper = new Member();
        wrapper.setRecId(member.getId());
        List<Member> list = memberService.findList(wrapper);
        List<Integer> collect = list.stream().map(s -> s.getId()).collect(Collectors.toList());
 
        CoffeeBeanMemberDTO coffeeBeanMemberDTO = new CoffeeBeanMemberDTO();
        coffeeBeanMemberDTO.setMemberId(member.getId());
        coffeeBeanMemberDTO.setCoffeeBeanCount(member.getIntegral());
        coffeeBeanMemberDTO.setRecIds(collect);
 
        return coffeeBeanMemberDTO;
    }
}