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();
|
}
|
|
}
|
|
}
|