|
|
@@ -13,10 +13,7 @@ import com.fs.common.core.page.PageRequest;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.core.redis.RedisUtil;
|
|
|
import com.fs.core.aspectj.lock.DistributeLock;
|
|
|
-import com.fs.live.domain.Live;
|
|
|
-import com.fs.live.domain.LiveLotteryRegistration;
|
|
|
-import com.fs.live.domain.LiveRedConf;
|
|
|
-import com.fs.live.domain.LiveWatchUser;
|
|
|
+import com.fs.live.domain.*;
|
|
|
import com.fs.live.param.CouponPO;
|
|
|
import com.fs.live.param.LotteryPO;
|
|
|
import com.fs.live.param.RedPO;
|
|
|
@@ -60,6 +57,10 @@ public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeS
|
|
|
@Autowired
|
|
|
private ILiveLotteryConfService liveLotteryConfService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ILiveCompletionPointsRecordService completionPointsRecordService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public R liveList(PageRequest pageRequest) {
|
|
|
int start = (pageRequest.getCurrentPage() - 1) * pageRequest.getPageSize();
|
|
|
@@ -168,6 +169,83 @@ public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeS
|
|
|
return R.ok().put("data", liveVo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R liveDetailWithUserId(Long id, Long userId) {
|
|
|
+ Object o = redisUtil.hashGet(LiveKeysConstant.LIVE_HOME_PAGE_DETAIL, String.valueOf(id));
|
|
|
+ LiveVo liveVo;
|
|
|
+ if (ObjectUtil.isNotEmpty(o)) {
|
|
|
+ liveVo = JSON.parseObject(o.toString(), LiveVo.class);
|
|
|
+ } else {
|
|
|
+ liveVo = liveService.asyncToCacheLiveDetail(id);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(liveVo)) {
|
|
|
+ R.error("未找到直播");
|
|
|
+ }
|
|
|
+ if(liveVo.getIsShow() == 2) {
|
|
|
+ return R.error("直播未开放");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询用户今天是否已领取完课奖励
|
|
|
+ if (userId != null) {
|
|
|
+ try {
|
|
|
+ List<LiveCompletionPointsRecord> unreceivedRecords =
|
|
|
+ completionPointsRecordService.getUserUnreceivedRecords(id, userId);
|
|
|
+
|
|
|
+ // 判断是否有未领取的奖励,如果有则说明今天还未领取
|
|
|
+ // 如果没有未领取的,再查询是否有已领取的记录
|
|
|
+ if (unreceivedRecords != null && !unreceivedRecords.isEmpty()) {
|
|
|
+ liveVo.setTodayRewardReceived(false);
|
|
|
+ } else {
|
|
|
+ // 查询所有记录(包括已领取和未领取)
|
|
|
+ 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 &&
|
|
|
+ isSameDay(recordDate, today);
|
|
|
+
|
|
|
+ if (isSameDay && latestRecord.getReceiveStatus() == 1) {
|
|
|
+ liveVo.setTodayRewardReceived(true);
|
|
|
+ } else {
|
|
|
+ liveVo.setTodayRewardReceived(false);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ liveVo.setTodayRewardReceived(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询用户完课奖励领取状态失败, liveId={}, userId={}", id, userId, e);
|
|
|
+ liveVo.setTodayRewardReceived(false);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ liveVo.setTodayRewardReceived(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok().put("data", liveVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断两个日期是否为同一天
|
|
|
+ */
|
|
|
+ private boolean isSameDay(Date date1, Date date2) {
|
|
|
+ if (date1 == null || date2 == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Calendar cal1 = Calendar.getInstance();
|
|
|
+ Calendar cal2 = Calendar.getInstance();
|
|
|
+ cal1.setTime(date1);
|
|
|
+ cal2.setTime(date2);
|
|
|
+ return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
|
|
|
+ cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public R currentActivities(Long liveId, String userId) {
|
|
|
// 直播间配置信息
|
|
|
@@ -212,6 +290,8 @@ public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeS
|
|
|
return iLiveCouponService.claimCoupon(coupon);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@DistributeLock(keyExpression = "#lottery.liveId +'_'+#lottery.userId", scene = "draw_claim")
|
|
|
public R drawClaim(LotteryPO lottery) {
|