|
|
@@ -5,6 +5,7 @@ import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.DictUtils;
|
|
|
import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.live.domain.Live;
|
|
|
import com.fs.live.domain.LiveConsoleOpLog;
|
|
|
import com.fs.live.domain.LiveConsoleOpLogUser;
|
|
|
import com.fs.live.domain.LiveCoupon;
|
|
|
@@ -19,7 +20,10 @@ import com.fs.live.service.ILiveConsoleOpLogService;
|
|
|
import com.fs.live.service.ILiveCouponIssueService;
|
|
|
import com.fs.live.service.ILiveLotteryConfService;
|
|
|
import com.fs.live.service.ILiveRedConfService;
|
|
|
+import com.fs.live.service.ILiveService;
|
|
|
+import com.fs.live.service.ILiveWatchUserService;
|
|
|
import com.fs.live.vo.LiveConsoleOpLogRecordVo;
|
|
|
+import com.fs.live.vo.LiveUserRewardRecordsVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
@@ -33,6 +37,8 @@ import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
|
|
|
/**
|
|
|
* 直播中控台操作留存 Service 实现
|
|
|
@@ -63,6 +69,12 @@ public class LiveConsoleOpLogServiceImpl implements ILiveConsoleOpLogService {
|
|
|
@Autowired
|
|
|
private LiveCouponMapper liveCouponMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ILiveService liveService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ILiveWatchUserService liveWatchUserService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<LiveConsoleOpLog> selectLiveConsoleOpLogList(LiveConsoleOpLog liveConsoleOpLog) {
|
|
|
return liveConsoleOpLogMapper.selectLiveConsoleOpLogList(liveConsoleOpLog);
|
|
|
@@ -210,6 +222,37 @@ public class LiveConsoleOpLogServiceImpl implements ILiveConsoleOpLogService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public LiveUserRewardRecordsVo getUserRewardRecords(Long liveId, Long userId) {
|
|
|
+ LiveUserRewardRecordsVo vo = new LiveUserRewardRecordsVo();
|
|
|
+ vo.setRecords(listUserOpLogRecords(liveId, userId));
|
|
|
+ vo.setLiveDuration(resolveLiveDuration(liveId));
|
|
|
+ vo.setWatchDuration(liveWatchUserService.getUserWatchDuration(liveId, userId));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long resolveLiveDuration(Long liveId) {
|
|
|
+ if (liveId == null) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+ Live live = liveService.selectLiveByLiveId(liveId);
|
|
|
+ if (live == null) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+ if (live.getDuration() != null && live.getDuration() > 0) {
|
|
|
+ return live.getDuration();
|
|
|
+ }
|
|
|
+ if (live.getVideoDuration() != null && live.getVideoDuration() > 0) {
|
|
|
+ return live.getVideoDuration();
|
|
|
+ }
|
|
|
+ if (live.getStartTime() != null) {
|
|
|
+ LocalDateTime endTime = live.getFinishTime() != null ? live.getFinishTime() : LocalDateTime.now();
|
|
|
+ long seconds = ChronoUnit.SECONDS.between(live.getStartTime(), endTime);
|
|
|
+ return Math.max(seconds, 0L);
|
|
|
+ }
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 状态优先级:已领取 > 已结束 > 待领取
|
|
|
*/
|