|
|
@ -17,6 +17,7 @@ import org.springframework.stereotype.Component; |
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
import java.time.YearMonth; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@Component |
|
|
@Component |
|
|
@ -30,28 +31,67 @@ public class AcquireGiftRightTask { |
|
|
@Resource |
|
|
@Resource |
|
|
private RightAcquireRecordDao rightAcquireRecordDao; |
|
|
private RightAcquireRecordDao rightAcquireRecordDao; |
|
|
|
|
|
|
|
|
|
|
|
// /** |
|
|
|
|
|
// * 每月给资料赠送修改头像权益 人数多不能这么领取,用户自己领取就行 |
|
|
|
|
|
// */ |
|
|
|
|
|
// @Scheduled(cron = "0 0 0 * * *") // 每天凌晨执行 |
|
|
|
|
|
// public void handle() { |
|
|
|
|
|
// try { |
|
|
|
|
|
// log.error("赠送权益任务开始"); |
|
|
|
|
|
// //一个月整前的资料赠送权益 |
|
|
|
|
|
// LocalDate date = LocalDate.now().minusMonths(1); |
|
|
|
|
|
// LocalDateTime startTime = date.atTime(0, 0, 0); |
|
|
|
|
|
// LocalDateTime endTime = date.atTime(23, 59, 59); |
|
|
|
|
|
// LocalDateTime todayStartTime = LocalDate.now().atTime(0, 0, 0); |
|
|
|
|
|
// LocalDateTime todayEndTime = LocalDate.now().atTime(23, 59, 59); |
|
|
|
|
|
// int count = userMarriageInformationDao.selectCount(new LambdaQueryWrapper<UserMarriageInformation>() |
|
|
|
|
|
// .ge(UserMarriageInformation::getCreateTime, startTime) |
|
|
|
|
|
// .le(UserMarriageInformation::getCreateTime, endTime)); |
|
|
|
|
|
// if (count > 0) { |
|
|
|
|
|
// int num = 100; |
|
|
|
|
|
// for (int i = 0; i < count; i += num) { |
|
|
|
|
|
// List<UserMarriageInformation> list = userMarriageInformationDao.selectList(new LambdaQueryWrapper<UserMarriageInformation>() |
|
|
|
|
|
// .ge(UserMarriageInformation::getCreateTime, startTime) |
|
|
|
|
|
// .le(UserMarriageInformation::getCreateTime, endTime) |
|
|
|
|
|
// .last("limit " + i + "," + num)); |
|
|
|
|
|
// if (CollUtil.isNotEmpty(list)) { |
|
|
|
|
|
// for (UserMarriageInformation userMarriageInformation : list) { |
|
|
|
|
|
// //判断资料是否领取过免费权益 |
|
|
|
|
|
// if (rightAcquireRecordDao.selectCount(new LambdaQueryWrapper<RightAcquireRecord>() |
|
|
|
|
|
// .eq(RightAcquireRecord::getUserId, userMarriageInformation.getUserId()) |
|
|
|
|
|
// .eq(RightAcquireRecord::getMiId, userMarriageInformation.getMiId()) |
|
|
|
|
|
// .eq(RightAcquireRecord::getAcquireType, RightAcquireEnum.GIFT) |
|
|
|
|
|
// .ge(RightAcquireRecord::getCreateTime, todayStartTime) |
|
|
|
|
|
// .le(RightAcquireRecord::getCreateTime, todayEndTime)) == 0) { |
|
|
|
|
|
// rightApplicationService.acquireNewMIRight(userMarriageInformation.getUserId(), userMarriageInformation.getMiId()); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// log.error("赠送权益任务结束"); |
|
|
|
|
|
// } |
|
|
|
|
|
// } catch (Exception e) { |
|
|
|
|
|
// log.error("赠送权益任务异常", e); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 每月给资料赠送修改头像权益 人数多不能这么领取,用户自己领取就行 |
|
|
* 每月给资料赠送修改头像权益 人数多不能这么领取,用户自己领取就行 |
|
|
*/ |
|
|
*/ |
|
|
@Scheduled(cron = "0 0 0 * * *") // 每天凌晨执行 |
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 * 0 * * *") // 每月1号凌晨执行 |
|
|
public void handle() { |
|
|
public void handle() { |
|
|
try { |
|
|
try { |
|
|
log.error("赠送权益任务开始"); |
|
|
log.error("赠送权益任务开始"); |
|
|
//一个月整前的资料赠送权益 |
|
|
//一个月整前的资料赠送权益 |
|
|
LocalDate date = LocalDate.now().minusMonths(1); |
|
|
|
|
|
LocalDateTime startTime = date.atTime(0, 0, 0); |
|
|
|
|
|
LocalDateTime endTime = date.atTime(23, 59, 59); |
|
|
|
|
|
LocalDateTime todayStartTime = LocalDate.now().atTime(0, 0, 0); |
|
|
|
|
|
LocalDateTime todayEndTime = LocalDate.now().atTime(23, 59, 59); |
|
|
|
|
|
int count = userMarriageInformationDao.selectCount(new LambdaQueryWrapper<UserMarriageInformation>() |
|
|
|
|
|
.ge(UserMarriageInformation::getCreateTime, startTime) |
|
|
|
|
|
.le(UserMarriageInformation::getCreateTime, endTime)); |
|
|
|
|
|
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
LocalDateTime monthStartTime = YearMonth.from(now).atDay(1).atTime(0, 0, 0); |
|
|
|
|
|
LocalDateTime monthEndTime = YearMonth.from(now).plusMonths(1).atDay(1).minusDays(1).atTime(23, 59, 59); |
|
|
|
|
|
int count = userMarriageInformationDao.selectCount(new LambdaQueryWrapper<UserMarriageInformation>()); |
|
|
if (count > 0) { |
|
|
if (count > 0) { |
|
|
int num = 100; |
|
|
int num = 100; |
|
|
for (int i = 0; i < count; i += num) { |
|
|
for (int i = 0; i < count; i += num) { |
|
|
List<UserMarriageInformation> list = userMarriageInformationDao.selectList(new LambdaQueryWrapper<UserMarriageInformation>() |
|
|
List<UserMarriageInformation> list = userMarriageInformationDao.selectList(new LambdaQueryWrapper<UserMarriageInformation>() |
|
|
.ge(UserMarriageInformation::getCreateTime, startTime) |
|
|
|
|
|
.le(UserMarriageInformation::getCreateTime, endTime) |
|
|
|
|
|
.last("limit " + i + "," + num)); |
|
|
.last("limit " + i + "," + num)); |
|
|
if (CollUtil.isNotEmpty(list)) { |
|
|
if (CollUtil.isNotEmpty(list)) { |
|
|
for (UserMarriageInformation userMarriageInformation : list) { |
|
|
for (UserMarriageInformation userMarriageInformation : list) { |
|
|
@ -60,8 +100,8 @@ public class AcquireGiftRightTask { |
|
|
.eq(RightAcquireRecord::getUserId, userMarriageInformation.getUserId()) |
|
|
.eq(RightAcquireRecord::getUserId, userMarriageInformation.getUserId()) |
|
|
.eq(RightAcquireRecord::getMiId, userMarriageInformation.getMiId()) |
|
|
.eq(RightAcquireRecord::getMiId, userMarriageInformation.getMiId()) |
|
|
.eq(RightAcquireRecord::getAcquireType, RightAcquireEnum.GIFT) |
|
|
.eq(RightAcquireRecord::getAcquireType, RightAcquireEnum.GIFT) |
|
|
.ge(RightAcquireRecord::getCreateTime, todayStartTime) |
|
|
|
|
|
.le(RightAcquireRecord::getCreateTime, todayEndTime)) == 0) { |
|
|
|
|
|
|
|
|
.ge(RightAcquireRecord::getCreateTime, monthStartTime) |
|
|
|
|
|
.le(RightAcquireRecord::getCreateTime, monthEndTime)) == 0) { |
|
|
rightApplicationService.acquireNewMIRight(userMarriageInformation.getUserId(), userMarriageInformation.getMiId()); |
|
|
rightApplicationService.acquireNewMIRight(userMarriageInformation.getUserId(), userMarriageInformation.getMiId()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|