admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
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
package com.yeshi.fanli.job;
 
import java.util.ArrayList;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.msg.UserInviteMsgNotificationService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.Constant;
 
@Component
public class UpdateThreeSaleJob {
 
    @Resource
    private ThreeSaleSerivce ThreeSaleSerivce;
    @Resource
    private UserInviteMsgNotificationService userInviteMsgNotificationService;
 
    @Resource
    private UserInfoService userInfoService;
 
    // 每天00点20执行 过期邀请筛选
    @Scheduled(cron = "0 20 0 * * ? ")
    public void updateReward() {
 
        if (!Constant.IS_TASK) {
            return;
        }
 
        try {
            List<Long> list = new ArrayList<Long>();
 
            // 发出邀请未成功 超过60天
            List<Long> listFailed = ThreeSaleSerivce.queryLongTimeFailed(60);
            if (listFailed != null && listFailed.size() > 0) {
                list.addAll(listFailed);
            }
 
            // 更新邀请过期: 60天未被邀请成功、60天未登陆系统
            if (list.size() > 0) {
                ThreeSaleSerivce.updateExpire(list);
                for (Long id : listFailed) {
                    // 通知
                    ThreeSale ts = ThreeSaleSerivce.selectByPrimaryKey(id);
                    if (ts != null)
                        userInviteMsgNotificationService.inviteFail(ts.getBoss().getId(), ts);
                }
            }
 
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
 
}