Browse Source

fix 直播

he2802 3 years ago
parent
commit
744073ad35

+ 10 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/order/OrderGoodsController.java

@@ -1,5 +1,7 @@
 package com.zhongzheng.controller.order;
 
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.util.List;
 import java.util.Arrays;
 
@@ -14,6 +16,7 @@ import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import com.zhongzheng.modules.user.service.IUserStudyRecordService;
 import com.zhongzheng.modules.user.vo.SectionStudyRecordVo;
 import lombok.RequiredArgsConstructor;
+import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -167,4 +170,11 @@ public class OrderGoodsController extends BaseController {
         List<SectionStudyRecordVo> list = iUserStudyRecordService.userSectionLiveList(bo);
         return getDataTable(list);
     }
+
+    @ApiOperation("保利威用户学习时间日志")
+    @PreAuthorize("@ss.hasPermi('system:invoice:list')")
+    @GetMapping("/userSectionLiveLog")
+    public AjaxResult<List<LiveListChannelViewlogResponse.LiveChannelViewlog>> userSectionLiveLog(UserStudyRecordQueryBo bo) throws IOException, NoSuchAlgorithmException {
+        return AjaxResult.success(iUserStudyRecordService.userSectionLiveLog(bo));
+    }
 }

+ 13 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -24,11 +24,13 @@ import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
+import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
 import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
+import com.zhongzheng.modules.order.vo.OrderGoodsVo;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamWrongRecordQueryBo;
 import com.zhongzheng.modules.user.domain.User;
@@ -188,5 +190,15 @@ public class GoodsController extends BaseController {
         return AjaxResult.success(iUserPeriodService.todayStudySectionNum(bo));
     }
 
-
+    /**
+     * 查询商品列表
+     */
+    @ApiOperation("查询用户拥有直播商品")
+    @GetMapping("/listGoodsUserQuestion")
+    public TableDataInfo<OrderGoodsVo> listGoodsUserQuestionVo(GoodsQueryBo bo) {
+        startPage();
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        List<OrderGoodsVo> list = iOrderGoodsService.listGoodsUserLive(loginUser.getUser().getUserId());
+        return getDataTable(list);
+    }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsMapper.java

@@ -42,4 +42,6 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
     List<OrderGoodsVo> selectBuyGoodsUserList(OrderGoodsQueryBo bo);
 
     List<OrderGoodsVo> listLiveGoodsList(GoodsQueryBo bo);
+
+    List<OrderGoodsVo> listGoodsUserLive(Long userId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsService.java

@@ -81,4 +81,6 @@ public interface IOrderGoodsService extends IService<OrderGoods> {
     List<OrderGoodsVo> selectBuyGoodsUserList(OrderGoodsQueryBo bo);
 
     List<OrderGoodsVo> listLiveGoodsList(GoodsQueryBo bo);
+
+    List<OrderGoodsVo> listGoodsUserLive(Long userId);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -352,6 +352,11 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         return list;
     }
 
+    @Override
+    public List<OrderGoodsVo> listGoodsUserLive(Long userId) {
+        return this.baseMapper.listGoodsUserLive(userId);
+    }
+
     public boolean joinGrade(Long orderGoodsId, Long gradeId, Long userId, Long goodsId) {
         ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
         if (classGradeVo == null) {

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/bo/PolyvLiveQueryBo.java

@@ -26,4 +26,14 @@ public class PolyvLiveQueryBo extends BaseEntity {
 	private Long sectionId;
 	@ApiModelProperty("场次ID")
 	private String sessionId;
+	@ApiModelProperty("查询开始时间")
+	private Long startTime;
+	@ApiModelProperty("查询结束时间")
+	private Long endTime;
+	@ApiModelProperty("用户账号")
+	private String userAccount;
+	@ApiModelProperty("当前页")
+	private Integer currentPage;
+	@ApiModelProperty("页面大小")
+	private Integer pageSize;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/service/IPolyvLiveService.java

@@ -14,6 +14,7 @@ import com.zhongzheng.modules.polyv.vo.PolyvVo;
 import net.polyv.live.v1.entity.channel.operate.LiveChannelBasicInfoResponse;
 import net.polyv.live.v1.entity.channel.playback.LiveChannelVideoListResponse;
 import net.polyv.live.v1.entity.channel.playback.LiveListChannelSessionInfoResponse;
+import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -38,4 +39,6 @@ public interface IPolyvLiveService {
 	LiveChannelVideoListResponse.ChannelVedioInfo getChannelVideo(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException;
 
 	LiveChannelBasicInfoResponse GetChannelBasicInfo(PolyvLiveQueryBo bo) throws Exception, NoSuchAlgorithmException;
+
+	List<LiveListChannelViewlogResponse.LiveChannelViewlog> ListChannelViewlog(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException;
 }

+ 30 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/service/impl/PolyvLiveServiceImpl.java

@@ -47,8 +47,11 @@ import net.polyv.live.v1.entity.channel.playback.LiveChannelVideoListRequest;
 import net.polyv.live.v1.entity.channel.playback.LiveChannelVideoListResponse;
 import net.polyv.live.v1.entity.channel.playback.LiveListChannelSessionInfoRequest;
 import net.polyv.live.v1.entity.channel.playback.LiveListChannelSessionInfoResponse;
+import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogRequest;
+import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
 import net.polyv.live.v1.service.channel.impl.LiveChannelOperateServiceImpl;
 import net.polyv.live.v1.service.channel.impl.LiveChannelPlaybackServiceImpl;
+import net.polyv.live.v1.service.channel.impl.LiveChannelViewdataServiceImpl;
 import net.polyv.live.v1.util.LiveSignUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -228,4 +231,31 @@ public class PolyvLiveServiceImpl implements IPolyvLiveService {
         }
         return null;
     }
+
+    @Override
+    public List<LiveListChannelViewlogResponse.LiveChannelViewlog> ListChannelViewlog(PolyvLiveQueryBo bo) throws IOException, NoSuchAlgorithmException {
+        LiveListChannelViewlogRequest liveListChannelViewlogRequest = new LiveListChannelViewlogRequest();
+        LiveListChannelViewlogResponse liveListChannelViewlogResponse;
+        if(Validator.isEmpty(bo.getStartTime())){
+            return new ArrayList<>();
+        }
+        try {
+            liveListChannelViewlogRequest.setChannelId(bo.getChannelId()).setViewerId(bo.getUserAccount()).setLogType("live")
+                    .setStartTime(new Date((bo.getStartTime()*1000))).setEndTime(new Date((bo.getEndTime()*1000)));
+            liveListChannelViewlogResponse = new LiveChannelViewdataServiceImpl().listChannelViewlog(
+                    liveListChannelViewlogRequest);
+
+            if (liveListChannelViewlogResponse != null) {
+                //to do something ......
+                return liveListChannelViewlogResponse.getContents();
+            }
+        } catch (PloyvSdkException e) {
+            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage(),B
+            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
+            throw e;
+        } catch (Exception e) {
+            throw e;
+        }
+        return null;
+    }
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java

@@ -7,8 +7,11 @@ import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
 import com.zhongzheng.modules.user.vo.*;
+import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
 import org.apache.ibatis.annotations.Param;
 
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.util.Collection;
 import java.util.List;
 
@@ -91,4 +94,6 @@ public interface IUserStudyRecordService extends IService<UserStudyRecord> {
 	SectionStudyRecordVo getLastLive(UserStudyRecordQueryBo bo) throws Exception;
 
 	List<SectionStudyRecordVo> userSectionLiveList(UserStudyRecordQueryBo bo);
+
+	List<LiveListChannelViewlogResponse.LiveChannelViewlog> userSectionLiveLog(UserStudyRecordQueryBo bo) throws IOException, NoSuchAlgorithmException;
 }

+ 19 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -50,6 +50,7 @@ import com.zhongzheng.modules.user.mapper.UserStudyRecordMapper;
 import com.zhongzheng.modules.user.service.*;
 import com.zhongzheng.modules.user.vo.*;
 import net.polyv.live.v1.entity.channel.operate.LiveChannelBasicInfoResponse;
+import net.polyv.live.v1.entity.channel.viewdata.LiveListChannelViewlogResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -59,7 +60,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.IOException;
 import java.math.BigDecimal;
+import java.security.NoSuchAlgorithmException;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -105,13 +108,15 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
     @Autowired
     private ICourseChapterSectionService iCourseChapterSectionService;
 
-
     @Autowired
     private com.zhongzheng.modules.alisms.service.IAliSmsService IAliSmsService;
 
     @Autowired
     private IUserService iUserService;
 
+    @Autowired
+    private IPolyvLiveService iPolyvLiveService;
+
     @Autowired
     private IInformUserService iInformUserService;
 
@@ -126,8 +131,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
     private IUserBankRecordService iUserBankRecordService;
     @Autowired
     private IUserExamGoodsService iUserExamGoodsService;
-    @Autowired
-    private IPolyvLiveService iPolyvLiveService;
+
     @Autowired
     private  RedisCache redisCache;
     @Override
@@ -540,6 +544,18 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
         return this.baseMapper.userSectionLiveList(bo);
     }
 
+    @Override
+    public List<LiveListChannelViewlogResponse.LiveChannelViewlog> userSectionLiveLog(UserStudyRecordQueryBo bo) throws IOException, NoSuchAlgorithmException {
+        UserVo user = iUserService.queryById(bo.getUserId());
+        CourseSectionVo sectionVo = iCourseSectionService.queryById(bo.getSectionId());
+        PolyvLiveQueryBo queryBo = new PolyvLiveQueryBo();
+        queryBo.setUserAccount(user.getUserAccount());
+        queryBo.setChannelId(sectionVo.getLiveUrl());
+        queryBo.setStartTime(sectionVo.getRealLiveStartTime());
+        queryBo.setEndTime(sectionVo.getRealLiveEndTime());
+        return iPolyvLiveService.ListChannelViewlog(queryBo);
+    }
+
 
     //判断当前未看完的节是否是点击播放的节
     private boolean compareSection(UserStudyRecordVo recordVo,UserStudyRecordQueryBo entity){

+ 0 - 1
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -558,5 +558,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                                         ))))
     </select>
 
-
 </mapper>

+ 29 - 0
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -377,4 +377,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY og.create_time DESC
     </select>
 
+    <select id="listGoodsUserLive" parameterType="Long" resultMap="OrderGoodsResultVo">
+        SELECT
+            g.*,
+            cet.education_name,
+            cpt.project_name,
+            cb.business_name,
+            o.user_id,
+            og.create_time as order_create_time,
+            og.service_start_time,
+            og.service_end_time,
+            og.order_goods_id
+        FROM
+            order_goods og
+                LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
+                LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
+                LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
+                LEFT JOIN course_business cb ON g.business_id = cb.id
+                LEFT JOIN goods og on g.goods_id =og.goods_id
+                LEFT JOIN `order` o on o.order_sn = og.order_sn
+        WHERE
+            1 = 1
+          AND g.goods_type = 6
+          AND o.user_id=#{userId}
+          AND og.`status` =1
+          and og.pay_status in (2,3,4)
+          AND og.refund_status in (0,3,1)
+        ORDER BY og.create_time DESC
+    </select>
+
 </mapper>