|
|
@@ -14,6 +14,7 @@ import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.live.domain.*;
|
|
|
import com.fs.framework.aspectj.lock.DistributeLock;
|
|
|
import com.fs.live.param.CouponPO;
|
|
|
+import com.fs.live.param.LiveWatchProgressParam;
|
|
|
import com.fs.live.param.LotteryPO;
|
|
|
import com.fs.live.param.RedPO;
|
|
|
import com.fs.live.service.*;
|
|
|
@@ -52,10 +53,13 @@ public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeS
|
|
|
|
|
|
@Autowired
|
|
|
private ILiveLotteryConfService liveLotteryConfService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ILiveCompletionPointsRecordService completionPointsRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ILivePersonalizedPushService personalizedPushService;
|
|
|
+
|
|
|
@Override
|
|
|
public R liveList(PageRequest pageRequest) {
|
|
|
int start = (pageRequest.getCurrentPage() - 1) * pageRequest.getPageSize();
|
|
|
@@ -132,32 +136,32 @@ public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeS
|
|
|
if(liveVo.getIsShow() == 2) {
|
|
|
return R.error("直播未开放");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 查询用户今天是否已领取完课奖励
|
|
|
if (userId != null) {
|
|
|
try {
|
|
|
- List<LiveCompletionPointsRecord> unreceivedRecords =
|
|
|
+ List<LiveCompletionPointsRecord> unreceivedRecords =
|
|
|
completionPointsRecordService.getUserUnreceivedRecords(id, userId);
|
|
|
-
|
|
|
+
|
|
|
// 判断是否有未领取的奖励,如果有则说明今天还未领取
|
|
|
// 如果没有未领取的,再查询是否有已领取的记录
|
|
|
if (unreceivedRecords != null && !unreceivedRecords.isEmpty()) {
|
|
|
liveVo.setTodayRewardReceived(false);
|
|
|
} else {
|
|
|
// 查询所有记录(包括已领取和未领取)
|
|
|
- List<LiveCompletionPointsRecord> allRecords =
|
|
|
+ List<LiveCompletionPointsRecord> allRecords =
|
|
|
completionPointsRecordService.getUserRecords(id, userId);
|
|
|
-
|
|
|
+
|
|
|
if (allRecords != null && !allRecords.isEmpty()) {
|
|
|
// 检查最近一条记录是否是今天的且已领取
|
|
|
LiveCompletionPointsRecord latestRecord = allRecords.get(0);
|
|
|
Date today = new Date();
|
|
|
Date recordDate = latestRecord.getCurrentCompletionDate();
|
|
|
-
|
|
|
+
|
|
|
// 判断是否为同一天
|
|
|
- boolean isSameDay = recordDate != null &&
|
|
|
+ boolean isSameDay = recordDate != null &&
|
|
|
isSameDay(recordDate, today);
|
|
|
-
|
|
|
+
|
|
|
if (isSameDay && latestRecord.getReceiveStatus() == 1) {
|
|
|
liveVo.setTodayRewardReceived(true);
|
|
|
} else {
|
|
|
@@ -174,10 +178,10 @@ public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeS
|
|
|
} else {
|
|
|
liveVo.setTodayRewardReceived(false);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return R.ok().put("data", liveVo);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 判断两个日期是否为同一天
|
|
|
*/
|
|
|
@@ -226,6 +230,34 @@ public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeS
|
|
|
.put("topMsg", liveMsg);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R currentActivitiesWithProgress(Long liveId, String userId, Long currentProgress, Integer replayFlag) {
|
|
|
+ try {
|
|
|
+ LiveWatchProgressParam param = new LiveWatchProgressParam();
|
|
|
+ param.setLiveId(liveId);
|
|
|
+ param.setUserId(Long.parseLong(userId));
|
|
|
+ param.setCurrentProgress(currentProgress);
|
|
|
+ param.setReplayFlag(replayFlag);
|
|
|
+
|
|
|
+ R personalizedResult = personalizedPushService.reportProgressAndGetTasks(param);
|
|
|
+
|
|
|
+ R originalResult = currentActivities(liveId, userId);
|
|
|
+
|
|
|
+ // 合并结果,增加个性化推送的任务
|
|
|
+ if (personalizedResult != null && personalizedResult.get("code").equals(200)) {
|
|
|
+ originalResult.put("personalizedTasks", personalizedResult.get("tasks"));
|
|
|
+ } else {
|
|
|
+ originalResult.put("personalizedTasks", new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ return originalResult;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取录播个性化推送失败,liveId: {}, userId: {}", liveId, userId, e);
|
|
|
+ return currentActivities(liveId, userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@DistributeLock(keyExpression = "#red.redId +'_'+#red.userId", scene = "red_claim", waitTime = 1000, errorMsg = "红包领取失败")
|
|
|
public R redClaim(RedPO red) {
|