|
|
|
@ -7,7 +7,9 @@ import com.qniao.dam.domain.aggregate.right.valueobj.RightAcquireRecord; |
|
|
|
import com.qniao.dam.domian.aggregate.right.constant.RightAcquireEnum; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.domain.MarriageInformationDao; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.domain.RightAcquireRecordDao; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.domain.UserMarriageInformationDao; |
|
|
|
import com.qniao.das.domian.aggregate.marriageinformation.MarriageInformation; |
|
|
|
import com.qniao.das.domian.aggregate.marriageinformation.UserMarriageInformation; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
@ -22,7 +24,7 @@ import java.util.List; |
|
|
|
public class AcquireGiftRightTask { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private MarriageInformationDao marriageInformationDao; |
|
|
|
private UserMarriageInformationDao userMarriageInformationDao; |
|
|
|
@Resource |
|
|
|
private RightApplicationService rightApplicationService; |
|
|
|
@Resource |
|
|
|
@ -41,26 +43,26 @@ public class AcquireGiftRightTask { |
|
|
|
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 = marriageInformationDao.selectCount(new LambdaQueryWrapper<MarriageInformation>() |
|
|
|
.ge(MarriageInformation::getCreateTime, startTime) |
|
|
|
.le(MarriageInformation::getCreateTime, endTime)); |
|
|
|
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<MarriageInformation> list = marriageInformationDao.selectList(new LambdaQueryWrapper<MarriageInformation>() |
|
|
|
.ge(MarriageInformation::getCreateTime, startTime) |
|
|
|
.le(MarriageInformation::getCreateTime, endTime) |
|
|
|
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 (MarriageInformation marriageInformation : list) { |
|
|
|
for (UserMarriageInformation userMarriageInformation : list) { |
|
|
|
//判断资料是否领取过免费权益 |
|
|
|
if (rightAcquireRecordDao.selectCount(new LambdaQueryWrapper<RightAcquireRecord>() |
|
|
|
.eq(RightAcquireRecord::getUserId, marriageInformation.getUserId()) |
|
|
|
.eq(RightAcquireRecord::getMiId, marriageInformation.getId()) |
|
|
|
.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(marriageInformation.getUserId(), marriageInformation.getId()); |
|
|
|
rightApplicationService.acquireNewMIRight(userMarriageInformation.getUserId(), userMarriageInformation.getMiId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|