统计播放量 和 完播量

This commit is contained in:
GYJ
2024-12-05 17:32:04 +08:00
parent 8672a9f2c7
commit ada714d68e
8 changed files with 84 additions and 27 deletions

View File

@@ -181,6 +181,8 @@ public class AliossCourseController {
courseDetails.setTitleImg(image);
courseDetails.setContent(courseDetailsName);
courseDetails.setGoodNum(goodNum);
courseDetails.setViewCount(0L);
courseDetails.setPlayCompleteCount(0L);
if(i<=freeNum){
courseDetails.setPrice(BigDecimal.ZERO);
courseDetails.setIsPrice(2);

View File

@@ -28,67 +28,77 @@ public class AppCourseController extends AbstractController {
@ApiOperation("查询短剧信息")
public Result selectCourse(@ApiParam("") Integer page, @ApiParam("") Integer limit, @ApiParam("分类id") Long classifyId,
@ApiParam("搜索内容") String title, Long bannerId, Integer sort, String token, Integer isPrice,
Integer over,Integer wxCourse,Integer dyCourse,Integer wxShow,Integer dyShow, HttpServletRequest request) {
if(StringUtils.isEmpty(token)){
Integer over, Integer wxCourse, Integer dyCourse, Integer wxShow, Integer dyShow, HttpServletRequest request) {
if (StringUtils.isEmpty(token)) {
token = request.getHeader("Token");
if(StringUtils.isBlank(token)){
if (StringUtils.isBlank(token)) {
token = request.getParameter("Token");
}
}
return courseService.selectCourse(page, limit, classifyId, title,null,1,bannerId,sort,token,isPrice,
null, over,wxCourse,dyCourse,wxShow,dyShow);
return courseService.selectCourse(page, limit, classifyId, title, null, 1, bannerId, sort, token, isPrice,
null, over, wxCourse, dyCourse, wxShow, dyShow);
}
@GetMapping("/selectCourseDetailsById")
@ApiOperation("根据id查询短剧详情")
public Result selectCourseDetailsById(Long id,String token,String courseDetailsId){
return courseDetailsService.selectCourseDetailsById(id,token,courseDetailsId);
public Result selectCourseDetailsById(Long id, String token, String courseDetailsId) {
return courseDetailsService.selectCourseDetailsById(id, token, courseDetailsId);
}
@GetMapping("/selectCourseDetailsList")
@ApiOperation("查询推荐视频")
public Result selectCourseDetailsList(Integer page,Integer limit,String token,String randomNum,Integer wxShow,Integer dyShow){
return courseDetailsService.selectCourseDetailsList(page, limit, token,randomNum,wxShow,dyShow);
public Result selectCourseDetailsList(Integer page, Integer limit, String token, String randomNum, Integer wxShow, Integer dyShow) {
return courseDetailsService.selectCourseDetailsList(page, limit, token, randomNum, wxShow, dyShow);
}
@Login
@GetMapping("/selectCourseTitle")
@ApiOperation("模糊根据短剧标题查询短剧")
public Result selectCourseTitle(@ApiParam("") Integer page, @ApiParam("") Integer limit, @ApiParam("分类id") Long classifyId,
@ApiParam("搜索内容") String title,Long bannerId,Integer sort,String token, Integer isPrice,Integer over,
Integer wxCourse,Integer dyCourse,Integer wxShow,Integer dyShow) {
return courseService.selectCourse(page, limit, classifyId, title,null,1,bannerId,sort,token,isPrice,
null, over,wxCourse,dyCourse,wxShow,dyShow);
@ApiParam("搜索内容") String title, Long bannerId, Integer sort, String token, Integer isPrice, Integer over,
Integer wxCourse, Integer dyCourse, Integer wxShow, Integer dyShow) {
return courseService.selectCourse(page, limit, classifyId, title, null, 1, bannerId, sort, token, isPrice,
null, over, wxCourse, dyCourse, wxShow, dyShow);
}
@GetMapping("/selectCourseTitles")
@ApiOperation("模糊根据短剧标题查询短剧")
public Result selectCourseTitles(@ApiParam("") Integer page, @ApiParam("") Integer limit, @ApiParam("分类id") Long classifyId,
@ApiParam("搜索内容") String title,Long bannerId,Integer sort,String token, Integer isPrice,Integer over,
Integer wxCourse,Integer dyCourse,Integer wxShow,Integer dyShow) {
return courseService.selectCourse(page, limit, classifyId, title,null,1,bannerId,sort,token,isPrice,
null, over,wxCourse,dyCourse,wxShow,dyShow);
@ApiParam("搜索内容") String title, Long bannerId, Integer sort, String token, Integer isPrice, Integer over,
Integer wxCourse, Integer dyCourse, Integer wxShow, Integer dyShow) {
return courseService.selectCourse(page, limit, classifyId, title, null, 1, bannerId, sort, token, isPrice,
null, over, wxCourse, dyCourse, wxShow, dyShow);
}
@Login
@PostMapping("/courseNotify")
@ApiOperation("看广告解锁视频")
public Result courseNotify(@RequestAttribute Long userId, Long courseId, Long courseDetailsId){
public Result courseNotify(@RequestAttribute Long userId, Long courseId, Long courseDetailsId) {
return courseService.courseNotify(userId, courseId, courseDetailsId);
}
@PostMapping("/notifyUrl")
@ApiOperation("抖音视频回调")
public JSONObject notifyUrl(@RequestBody JSONObject jsonObject){
public JSONObject notifyUrl(@RequestBody JSONObject jsonObject) {
return courseService.notifyUrl(jsonObject);
}
@PostMapping("/selectWxVideoUrl")
@ApiOperation("查询微信短剧播放链接")
public Result selectWxVideoUrl(@RequestBody JSONObject jsonObject){
public Result selectWxVideoUrl(@RequestBody JSONObject jsonObject) {
String wxCourseDetailsIds = jsonObject.getString("wxCourseDetailsIds");
return courseService.selectWxVideoUrl(wxCourseDetailsIds);
}
@Login
@GetMapping("/viewCourse")
@ApiOperation("查看短剧")
public Result viewCourse(@RequestAttribute Long userId,
@ApiParam("短剧id") Long courseId,
@ApiParam("剧集id") Long courseDetailsId,
@ApiParam("统计类型start 开始end 结束") String type) {
return courseService.viewCourse(userId, courseId, courseDetailsId, type);
}
}

View File

@@ -10,8 +10,8 @@ import java.io.Serializable;
import java.math.BigDecimal;
/**
* @description course_details 短剧目录
* @author fang
* @description course_details 短剧目录
* @date 2021-03-27
*/
@Data
@@ -133,6 +133,16 @@ public class CourseDetails implements Serializable {
*/
private Integer advertising;
/**
* 播放量
*/
private Long viewCount;
/**
* 完播量
*/
private Long playCompleteCount;
@TableField(exist = false)
private Integer isCollect;
@@ -145,5 +155,6 @@ public class CourseDetails implements Serializable {
@TableField(exist = false)
private String wxUrl;
public CourseDetails() {}
public CourseDetails() {
}
}

View File

@@ -59,4 +59,6 @@ public interface CourseService extends IService<Course> {
Result courseListExcelIn(MultipartFile file) throws IOException;
Result viewCourse(Long userId, Long courseId, Long courseDetailsId, String type);
}

View File

@@ -212,6 +212,8 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cou
CourseDetails courseDetails = new CourseDetails();
courseDetails.setCourseId(courseId);
courseDetails.setCreateTime(DateUtils.format(new Date()));
courseDetails.setViewCount(0L);
courseDetails.setPlayCompleteCount(0L);
BeanUtils.copyProperties(courseDetailsIn, courseDetails);
int result = baseMapper.insert(courseDetails);
if (result > 0) {

View File

@@ -89,6 +89,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
CourseDetails courseDetails=new CourseDetails();
courseDetails.setCourseId(course.getCourseId());
courseDetails.setVideoUrl(course.getRemark());
courseDetails.setViewCount(0L);
courseDetails.setPlayCompleteCount(0L);
courseDetailsDao.insert(courseDetails);
}else{
baseMapper.insert(course);
@@ -294,6 +296,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
courseDetails.setGoodNum(0);
courseDetails.setPrice(BigDecimal.ZERO);
courseDetails.setIsPrice(2);
courseDetails.setViewCount(0L);
courseDetails.setPlayCompleteCount(0L);
courseDetailsDao.insert(courseDetails);
}else{
CourseDetails courseDetails = courseDetailsDao.selectOne(new QueryWrapper<CourseDetails>().eq("course_details_name", name).last(" limit 1"));
@@ -1095,6 +1099,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
courseDetails.setTitleImg(img);
courseDetails.setContent(name);
courseDetails.setGoodNum(goodNum);
courseDetails.setViewCount(0L);
courseDetails.setPlayCompleteCount(0L);
if(i<=freeNum){
courseDetails.setPrice(BigDecimal.ZERO);
courseDetails.setIsPrice(2);
@@ -1227,5 +1233,29 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
}
@Override
public Result viewCourse(Long userId, Long courseId, Long courseDetailsId, String type) {
Course course = baseMapper.selectById(courseId);
if(course==null){
return Result.error("短剧不存在");
}
CourseDetails details = courseDetailsDao.selectById(courseDetailsId);
if(details==null){
return Result.error("短剧集不存在");
}
if ("start".equals(type)) {
//开始播放
details.setViewCount(details.getViewCount() + 1);
courseDetailsDao.updateById(details);
baseMapper.updateById(course);
} else if ("end".equals(type)) {
//播放完成
details.setPlayCompleteCount(details.getPlayCompleteCount() + 1);
courseDetailsDao.updateById(details);
}
return null;
}
}

View File

@@ -30,7 +30,7 @@
c.course_type as courseType,
c.banner_id as bannerId,
b.name as bannerName,
c.view_counts as viewCounts,
(select sum(cd.view_count) from course_details cd where cd.course_id = c.course_id ) as viewCounts,
c.dy_img_id as dyImgId,
c.dy_course_id as dyCourseId,
c.wx_course_id as wxCourseId,
@@ -148,7 +148,7 @@
c.course_type as courseType,
c.banner_id as bannerId,
b.name as bannerName,
c.view_counts as viewCounts,
(select sum(cd.view_count) from course_details cd where cd.course_id = c.course_id ) as viewCounts,
c.dy_img_id as dyImgId,
c.dy_course_id as dyCourseId,
c.dy_status as dyStatus,
@@ -278,4 +278,4 @@
order by create_time desc
</select>
</mapper>
</mapper>

View File

@@ -23,7 +23,7 @@
<select id="findByCourseIdNotUrl" resultType="com.sqx.modules.course.entity.CourseDetails">
select c.course_details_id as courseDetailsId,c.course_id as courseId,c.wx_course_details_id as wxCourseDetailsId,
c.course_details_name as courseDetailsName,c.create_time as createTime,
c.dy_episode_id as dyEpisodeId,c.advertising,
c.dy_episode_id as dyEpisodeId,c.advertising, c.view_count as viewCount, c.play_complete_count as playCompleteCount,
(select count(*) from course_collect cc where cc.user_id=#{userId} and cc.course_details_id=c.course_details_id and cc.classify=2) as isGood,
c.title_img as titleImg,c.content,c.good_num as goodNum,c.price,if(is_price!=1,c.video_url,'') as videoUrl
from course_details c
@@ -60,4 +60,4 @@
order by SUBSTR(uid, #{randomNum}, 6)
</select>
</mapper>
</mapper>