From 16a57a8fc6868cea9171a1119698572407a2fc03 Mon Sep 17 00:00:00 2001
From: hejianhao <15708179461@qq.com>
Date: 星期五, 28 八月 2026 15:21:46 +0800
Subject: [PATCH] fix0806: APP端去掉全部的市辖区选择
---
tcm-training-admin-backend/src/main/java/com/tcm/training/admin/app/course/service/AppHealthCourseService.java | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/tcm-training-admin-backend/src/main/java/com/tcm/training/admin/app/course/service/AppHealthCourseService.java b/tcm-training-admin-backend/src/main/java/com/tcm/training/admin/app/course/service/AppHealthCourseService.java
index 5d4fb5e..62cad09 100644
--- a/tcm-training-admin-backend/src/main/java/com/tcm/training/admin/app/course/service/AppHealthCourseService.java
+++ b/tcm-training-admin-backend/src/main/java/com/tcm/training/admin/app/course/service/AppHealthCourseService.java
@@ -311,17 +311,25 @@
HealthCourse course = requireEnabledCourse(courseId);
List<HealthCourseVideo> enabledVideos = listEnabledVideos(courseId);
Map<Long, VideoProgressSnapshot> videoProgressSnapshotMap = buildVideoProgressSnapshotMap(userId, Collections.singletonList(courseId));
+ PurchaseStateSnapshot purchaseStateSnapshot = resolvePurchaseState(courseId);
List<AppMyHealthCourseVideoItemVO> videos = new ArrayList<AppMyHealthCourseVideoItemVO>(enabledVideos.size());
Long currentVideoId = null;
LocalDateTime latestLearnAt = null;
for (HealthCourseVideo video : enabledVideos) {
VideoProgressSnapshot snapshot = videoProgressSnapshotMap.get(video.getId());
+ boolean freeAccess = isFreeVideo(video.getSalePrice());
+ boolean purchased = purchaseStateSnapshot.isCourseOwned()
+ || purchaseStateSnapshot.getPurchasedVideoIds().contains(video.getId());
+ boolean locked = !freeAccess && !purchased;
AppMyHealthCourseVideoItemVO itemVO = new AppMyHealthCourseVideoItemVO();
itemVO.setVideoId(video.getId());
itemVO.setChapterName(trimToEmpty(video.getChapterName()));
itemVO.setDurationSeconds(defaultNumber(video.getDurationSeconds()));
itemVO.setDurationText(formatVideoDuration(itemVO.getDurationSeconds()));
+ itemVO.setFreeAccess(Boolean.valueOf(freeAccess));
+ itemVO.setPurchased(Boolean.valueOf(purchased));
+ itemVO.setLocked(Boolean.valueOf(locked));
itemVO.setVideoUrl(trimToEmpty(video.getVideoUrl()));
itemVO.setCompleted(Boolean.valueOf(snapshot != null && snapshot.isCompleted()));
itemVO.setProgressPercent(Integer.valueOf(calculateVideoDisplayProgressPercent(
@@ -332,14 +340,20 @@
itemVO.setLastPlayPositionSeconds(Integer.valueOf(resolveVideoResumePosition(snapshot)));
itemVO.setDownloadable(Boolean.valueOf(hasVideoDownloadAccess(userId, courseId, video.getId())));
videos.add(itemVO);
- if (snapshot != null && snapshot.getLatestLearnAt() != null
+ // 默认播放章节只允许落在当前用户可观看的小节上,未购小节保留展示但不自动选中。
+ if (!locked && snapshot != null && snapshot.getLatestLearnAt() != null
&& (latestLearnAt == null || snapshot.getLatestLearnAt().isAfter(latestLearnAt))) {
latestLearnAt = snapshot.getLatestLearnAt();
currentVideoId = video.getId();
}
}
- if (currentVideoId == null && !enabledVideos.isEmpty()) {
- currentVideoId = enabledVideos.get(0).getId();
+ if (currentVideoId == null) {
+ for (AppMyHealthCourseVideoItemVO itemVO : videos) {
+ if (!Boolean.TRUE.equals(itemVO.getLocked())) {
+ currentVideoId = itemVO.getVideoId();
+ break;
+ }
+ }
}
AppMyHealthCourseDetailVO detailVO = new AppMyHealthCourseDetailVO();
@@ -508,9 +522,6 @@
AppUser user = requireEnabledUser(userId);
HealthCourse course = requireEnabledCourse(courseId);
String paymentMethod = normalizePaymentMethod(request == null ? null : request.getPaymentMethod());
- if (course.getSalePrice() == null || course.getSalePrice().compareTo(BigDecimal.ZERO) <= 0) {
- throw new IllegalArgumentException("当前课程无需购买");
- }
CoursePurchaseOrder existingOrder = findLatestActivePaidCourseOrder(userId, courseId);
if (existingOrder != null) {
return buildPurchaseResult(existingOrder, true, resolvePurchasedVideoIds(userId, courseId, true));
@@ -994,6 +1005,8 @@
videoVO.setLocked(Boolean.valueOf(locked));
// 已购买章节需要直接拿到视频地址,前端才能切换为下载入口。
videoVO.setVideoUrl(trimToEmpty(video.getVideoUrl()));
+ videoVO.setCreatedAt(video.getCreatedAt());
+ videoVO.setUpdatedAt(video.getUpdatedAt());
result.add(videoVO);
}
return result;
--
Gitblit v1.7.1