浏览代码

定时任务添加广播红包关闭消息,添加直播视频选择

yuhongqi 1 月之前
父节点
当前提交
1d45b8930d

+ 0 - 1
fs-company/src/main/java/com/fs/company/controller/live/LiveController.java

@@ -61,7 +61,6 @@ public class LiveController extends BaseController
     {
         // 设置企业ID和企业用户ID
         setCompanyId(live);
-        live.setCompanyUserId(null);
 
         startPage();
         List<Live> list = liveService.selectLiveList(live);

+ 2 - 2
fs-service-system/src/main/java/com/fs/live/domain/LiveVideo.java

@@ -17,7 +17,7 @@ import lombok.EqualsAndHashCode;
 public class LiveVideo extends BaseEntity {
 
     /** ID */
-    
+
     private Long videoId;
 
     /** 直播ID */
@@ -29,7 +29,7 @@ public class LiveVideo extends BaseEntity {
     private String videoUrl;
 
     /** 类型 1录播 2回放 */
-    @Excel(name = "类型 1录播 2回放")
+    @Excel(name = "类型 1录播 2回放 -1视频库")
     private Integer videoType;
 
     @Excel(name = "视屏时长")

+ 9 - 6
fs-service-system/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -248,12 +248,15 @@ public class LiveServiceImpl implements ILiveService
         live.setIsAudit(0);
         live.setStatus(1);
         int save = baseMapper.insertLive(live);
-        LiveVideo liveVideo = new LiveVideo();
-        liveVideo.setLiveId(live.getLiveId());
-        liveVideo.setVideoUrl(live.getVideoUrl());
-        liveVideo.setVideoType(1);
-        liveVideo.setDuration(live.getDuration());
-        liveVideoService.insertLiveVideo(liveVideo);
+        if (live.getLiveType() == 2) {
+            // 录播 才有视频
+            LiveVideo liveVideo = new LiveVideo();
+            liveVideo.setLiveId(live.getLiveId());
+            liveVideo.setVideoUrl(live.getVideoUrl());
+            liveVideo.setVideoType(1);
+            liveVideo.setDuration(live.getDuration());
+            liveVideoService.insertLiveVideo(liveVideo);
+        }
         //新增直播数据表
         LiveData liveData = new LiveData();
         liveData.setLiveId(live.getLiveId());

+ 5 - 0
fs-service-system/src/main/java/com/fs/live/service/impl/LiveVideoServiceImpl.java

@@ -68,6 +68,11 @@ public class LiveVideoServiceImpl implements ILiveVideoService
     @Override
     public int insertLiveVideo(LiveVideo liveVideo)
     {
+        // 直播ID为-1,则新增 直播视频库
+        if (liveVideo.getLiveId() == -1) {
+            liveVideo.setCreateTime(DateUtils.getNowDate());
+            return liveVideoMapper.insertLiveVideo(liveVideo);
+        }
         List<LiveVideo> liveVideos = liveVideoMapper.selectByLiveId(liveVideo.getLiveId());
         if (liveVideos!=null && !liveVideos.isEmpty()) {
             Date nowDate = DateUtils.getNowDate();

+ 2 - 7
fs-service-system/src/main/resources/mapper/live/LiveMapper.xml

@@ -55,20 +55,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
                a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
                a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url
-                <if test="companyId != null and companyUserId != null">
-                    ,c.live_code_url
-                </if>
+                ,c.live_code_url
 
         from live a
         left join live_video b on a.live_id = b.live_id
-        <if test="companyId != null and companyUserId != null">
             left join live_company_code c on a.live_id = c.live_id
             and c.company_id = #{companyId}
             and c.company_user_id = #{companyUserId}
-        </if>
         where 1=1 and is_del = 0
-        <if test="companyId != null "> and a.company_id = #{companyId}</if>
-        <if test="companyUserId != null "> and a.company_user_id = #{companyUserId}</if>
+        <if test="companyId != null "> and (a.company_id = #{companyId} or a.company_id is null )</if>
         <if test="talentId != null "> and talent_id = #{talentId}</if>
         <if test="liveName != null  and liveName != ''"> and live_name like concat('%', #{liveName}, '%')</if>
         <if test="liveDesc != null  and liveDesc != ''"> and live_desc = #{liveDesc}</if>

+ 5 - 1
fs-service-system/src/main/resources/mapper/live/LiveVideoMapper.xml

@@ -14,11 +14,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="duration"    column="duration"    />
         <result property="remark"    column="remark"    />
     </resultMap>
 
     <sql id="selectLiveVideoVo">
-        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark from live_video
+        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration from live_video
     </sql>
 
     <select id="selectLiveVideoList" parameterType="LiveVideo" resultMap="LiveVideoResult">
@@ -28,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="videoUrl != null  and videoUrl != ''"> and video_url = #{videoUrl}</if>
             <if test="videoType != null "> and video_type = #{videoType}</if>
             <if test="sort != null "> and sort = #{sort}</if>
+            <if test="remark != null "> and remark like CONCAT('%',#{remark},'%')</if>
         </where>
     </select>
 
@@ -52,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
+            <if test="duration != null">duration,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -63,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
+            <if test="duration != null">#{duration},</if>
          </trim>
     </insert>
 

+ 4 - 0
fs-user-app/src/main/java/com/fs/app/controller/LiveOrderController.java

@@ -14,6 +14,7 @@ import com.fs.common.exception.CustomException;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.utils.sign.Md5Utils;
 import com.fs.live.domain.Live;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.enums.LiveOrderCancleReason;
@@ -36,9 +37,12 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import static com.fs.live.service.impl.LiveServiceImpl.to16Hex;
+
 /**
  * 订单Controller
  *

+ 14 - 0
fs-user-app/src/main/java/com/fs/app/task/Task.java

@@ -38,6 +38,8 @@ import com.fs.store.service.IFsUserService;
 import lombok.AllArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.ObjectUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -54,6 +56,7 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class Task {
 
+    private static final Logger log = LoggerFactory.getLogger(Task.class);
     private final ILiveService liveService;
 
     private final ILiveDataService liveDataService;
@@ -197,9 +200,20 @@ public class Task {
             if (range == null || range.isEmpty()) {
                 continue;
             }
+
             updateRedStatus(range);
             redisCache.redisTemplate.opsForZSet()
                     .removeRangeByScore(liveKey, 0, currentTime);
+            try {
+                // 广播红包关闭消息
+                SendMsgVo sendMsgVo = new SendMsgVo();
+                sendMsgVo.setLiveId(Long.valueOf(liveKey));
+                sendMsgVo.setCmd("red");
+                sendMsgVo.setStatus(-1);
+                webSocketServer.broadcastMessage(Long.valueOf(liveKey), JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+            } catch (Exception e) {
+                log.error("更新红包状态异常", e);
+            }
         }
     }