|
@@ -5,11 +5,14 @@ import com.fs.common.annotation.RepeatSubmit;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.his.domain.FsUser;
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
import com.fs.his.service.IFsUserService;
|
|
|
|
|
+import com.fs.live.domain.Live;
|
|
|
import com.fs.live.domain.LiveCompletionPointsRecord;
|
|
import com.fs.live.domain.LiveCompletionPointsRecord;
|
|
|
import com.fs.live.service.ILiveCompletionPointsRecordService;
|
|
import com.fs.live.service.ILiveCompletionPointsRecordService;
|
|
|
|
|
+import com.fs.live.service.ILiveService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -27,6 +30,9 @@ public class LiveCompletionPointsController extends AppBaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsUserService fsUserService;
|
|
private IFsUserService fsUserService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ILiveService liveService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 领取完课积分
|
|
* 领取完课积分
|
|
|
*/
|
|
*/
|
|
@@ -64,20 +70,23 @@ public class LiveCompletionPointsController extends AppBaseController {
|
|
|
@GetMapping("/info")
|
|
@GetMapping("/info")
|
|
|
public R getInfo(@RequestParam Long liveId) {
|
|
public R getInfo(@RequestParam Long liveId) {
|
|
|
Long userId = Long.parseLong(getUserId());
|
|
Long userId = Long.parseLong(getUserId());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 1. 获取用户积分余额
|
|
// 1. 获取用户积分余额
|
|
|
FsUser user = fsUserService.selectFsUserByUserId(userId);
|
|
FsUser user = fsUserService.selectFsUserByUserId(userId);
|
|
|
Long integral = user != null && user.getIntegral() != null ? user.getIntegral() : 0L;
|
|
Long integral = user != null && user.getIntegral() != null ? user.getIntegral() : 0L;
|
|
|
-
|
|
|
|
|
- // 2. 获取完课记录列表(包含已领取和未领取)
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Live live = liveService.selectLiveByLiveId(liveId);
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 获取完课记录列表(包含已领取和未领取)
|
|
|
List<LiveCompletionPointsRecord> records = completionPointsRecordService.getUserRecords(liveId, userId);
|
|
List<LiveCompletionPointsRecord> records = completionPointsRecordService.getUserRecords(liveId, userId);
|
|
|
-
|
|
|
|
|
- // 3. 统计信息
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 统计信息
|
|
|
long totalPoints = records.stream()
|
|
long totalPoints = records.stream()
|
|
|
.filter(r -> r.getReceiveStatus() == 1)
|
|
.filter(r -> r.getReceiveStatus() == 1)
|
|
|
.mapToLong(LiveCompletionPointsRecord::getPointsAwarded)
|
|
.mapToLong(LiveCompletionPointsRecord::getPointsAwarded)
|
|
|
.sum();
|
|
.sum();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
long unreceivedCount = records.stream()
|
|
long unreceivedCount = records.stream()
|
|
|
.filter(r -> r.getReceiveStatus() == 0)
|
|
.filter(r -> r.getReceiveStatus() == 0)
|
|
|
.count();
|
|
.count();
|
|
@@ -88,7 +97,22 @@ public class LiveCompletionPointsController extends AppBaseController {
|
|
|
result.put("totalDays", records.size()); // 累计看直播天数
|
|
result.put("totalDays", records.size()); // 累计看直播天数
|
|
|
result.put("unreceivedCount", unreceivedCount); // 未领取记录数
|
|
result.put("unreceivedCount", unreceivedCount); // 未领取记录数
|
|
|
result.put("records", records); // 完课记录列表
|
|
result.put("records", records); // 完课记录列表
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 添加直播状态和时间信息
|
|
|
|
|
+ if (live != null) {
|
|
|
|
|
+ result.put("status", live.getStatus()); // 直播状态
|
|
|
|
|
+ result.put("startTime", live.getStartTime()); // 预告时间
|
|
|
|
|
+ result.put("duration", live.getDuration()); // 直播总时长(秒)
|
|
|
|
|
+
|
|
|
|
|
+ // 当status=2作为真开开始hide时间
|
|
|
|
|
+ if (live.getStatus() != null && live.getStatus() == 2) {
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+
|
|
|
|
|
+ result.put("serverTime", now);
|
|
|
|
|
+ result.put("totalDuration", live.getDuration()); // 直播总时长(秒)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return R.ok().put("data", result);
|
|
return R.ok().put("data", result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -98,7 +122,7 @@ public class LiveCompletionPointsController extends AppBaseController {
|
|
|
@PostMapping("/test/create")
|
|
@PostMapping("/test/create")
|
|
|
public R testCreateRecord(@RequestParam Long liveId, @RequestParam(required = false) Long watchDuration) {
|
|
public R testCreateRecord(@RequestParam Long liveId, @RequestParam(required = false) Long watchDuration) {
|
|
|
Long userId = Long.parseLong(getUserId());
|
|
Long userId = Long.parseLong(getUserId());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
// 调用完课记录创建方法(watchDuration为null时会自动从数据库累计)
|
|
// 调用完课记录创建方法(watchDuration为null时会自动从数据库累计)
|
|
|
completionPointsRecordService.checkAndCreateCompletionRecord(liveId, userId, watchDuration);
|
|
completionPointsRecordService.checkAndCreateCompletionRecord(liveId, userId, watchDuration);
|