Browse Source

直播最大人数在线统计修改 直播定时任务修改权限

yuhongqi 3 weeks ago
parent
commit
202d021494
29 changed files with 345 additions and 21 deletions
  1. 24 4
      fs-admin/src/main/java/com/fs/company/controller/CompanyController.java
  2. 3 3
      fs-admin/src/main/java/com/fs/live/controller/LiveAutoTaskController.java
  3. 16 0
      fs-admin/src/main/java/com/fs/live/controller/LiveCouponController.java
  4. 6 6
      fs-admin/src/main/java/com/fs/live/controller/LiveCouponUserController.java
  5. 13 0
      fs-company/src/main/java/com/fs/company/controller/live/LiveCouponController.java
  6. 20 0
      fs-live-socket/src/main/java/com/fs/live/controller/LiveController.java
  7. 23 0
      fs-live-socket/src/main/java/com/fs/live/websocket/service/WebSocketServer.java
  8. 31 0
      fs-service-system/src/main/java/com/fs/company/mapper/CompanyMapper.java
  9. 15 0
      fs-service-system/src/main/java/com/fs/company/param/CompanyLiveShowParam.java
  10. 9 0
      fs-service-system/src/main/java/com/fs/company/param/CompanyParam.java
  11. 5 0
      fs-service-system/src/main/java/com/fs/company/service/ICompanyService.java
  12. 17 0
      fs-service-system/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java
  13. 1 0
      fs-service-system/src/main/java/com/fs/company/vo/CompanyVO.java
  14. 2 0
      fs-service-system/src/main/java/com/fs/live/domain/LiveVideo.java
  15. 3 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveCouponIssueMapper.java
  16. 17 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveCouponMapper.java
  17. 5 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveMapper.java
  18. 4 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveVideoMapper.java
  19. 2 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveCouponIssueService.java
  20. 2 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveCouponService.java
  21. 3 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveCouponUserService.java
  22. 2 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveVideoService.java
  23. 31 5
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java
  24. 5 0
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveCouponIssueServiceImpl.java
  25. 5 0
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveCouponServiceImpl.java
  26. 25 2
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java
  27. 6 0
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveVideoServiceImpl.java
  28. 44 0
      fs-service-system/src/main/resources/mapper/live/LiveMapper.xml
  29. 6 1
      fs-service-system/src/main/resources/mapper/live/LiveVideoMapper.xml

+ 24 - 4
fs-admin/src/main/java/com/fs/company/controller/CompanyController.java

@@ -15,10 +15,7 @@ import com.fs.common.utils.ParseUtils;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.sign.Md5Utils;
 import com.fs.company.domain.*;
-import com.fs.company.param.CompanyDeductParam;
-import com.fs.company.param.CompanyParam;
-import com.fs.company.param.CompanyRechargeParam;
-import com.fs.company.param.CompanyVoiceCallerParam;
+import com.fs.company.param.*;
 import com.fs.company.service.*;
 import com.fs.company.vo.CompanyCrmVO;
 import com.fs.company.vo.CompanyVO;
@@ -70,6 +67,29 @@ public class CompanyController extends BaseController
     private ICompanyDeductService deductService;
     @Autowired
     private ICompanyVoiceCallerService callerService;
+    /**
+     * 查询企业列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:liveMiniLives:list')")
+    @GetMapping("/liveShowList")
+    public TableDataInfo liveShowList(CompanyParam param) throws ParseException {
+        startPage();
+        List<CompanyVO> list = companyService.liveShowList(param);
+        for (CompanyVO vo : list){
+            vo.setCompanyMobile(ParseUtils.parsePhone(vo.getCompanyMobile()));
+        }
+        return getDataTable(list);
+    }
+
+    @PostMapping(value = "/batchUpdateLiveShow")
+    public R batchUpdateLiveShow(@RequestBody CompanyLiveShowParam param) {
+        if (param.getIds().isEmpty()) {
+            return R.error("请选择要操作的记录");
+        }
+        companyService.batchUpdateLiveShow(param);
+        return R.ok();
+    }
+
     /**
      * 查询企业列表
      */

+ 3 - 3
fs-admin/src/main/java/com/fs/live/controller/LiveAutoTaskController.java

@@ -92,7 +92,7 @@ public class LiveAutoTaskController extends BaseController
     /**
      * 新增直播间自动化任务配置
      */
-//    @PreAuthorize("@ss.hasPermi('live:task:add')")
+    @PreAuthorize("@ss.hasPermi('live:task:add')")
     @Log(title = "直播间自动化任务配置", businessType = BusinessType.INSERT)
     @PostMapping
     public R add(@RequestBody LiveAutoTask liveAutoTask)
@@ -103,7 +103,7 @@ public class LiveAutoTaskController extends BaseController
     /**
      * 修改直播间自动化任务配置
      */
-//    @PreAuthorize("@ss.hasPermi('live:task:edit')")
+    @PreAuthorize("@ss.hasPermi('live:task:edit')")
     @Log(title = "直播间自动化任务配置", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody LiveAutoTask liveAutoTask)
@@ -114,7 +114,7 @@ public class LiveAutoTaskController extends BaseController
     /**
      * 删除直播间自动化任务配置
      */
-//    @PreAuthorize("@ss.hasPermi('live:task:remove')")
+    @PreAuthorize("@ss.hasPermi('live:task:remove')")
     @Log(title = "直播间自动化任务配置", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)

+ 16 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveCouponController.java

@@ -44,6 +44,8 @@ public class LiveCouponController extends BaseController
     private ILiveCouponIssueService liveCouponIssueService;
 
 
+
+
     /**
      * 查询优惠券列表
      */
@@ -57,6 +59,7 @@ public class LiveCouponController extends BaseController
         return getDataTable(list);
     }
 
+
     /**
      * 导出优惠券列表
      */
@@ -173,6 +176,19 @@ public class LiveCouponController extends BaseController
     }
 
 
+    /**
+     * 查询优惠券列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:liveCoupon:list')")
+    @GetMapping("/listOn")
+    public TableDataInfo listOn(@RequestParam("liveId") Long liveId)
+    {
+        startPage();
+        List<LiveCoupon> list = liveCouponService.listOn(liveId);
+        return getDataTable(list);
+    }
+
+
     @PreAuthorize("@ss.hasPermi('live:liveCoupon:add')")
     @Log(title = "直播优惠券", businessType = BusinessType.INSERT)
     @PostMapping("/delLiveCoupon")

+ 6 - 6
fs-admin/src/main/java/com/fs/live/controller/LiveCouponUserController.java

@@ -39,7 +39,7 @@ public class LiveCouponUserController extends BaseController
     /**
      * 查询优惠券发放记录列表
      */
-    @PreAuthorize("@ss.hasPermi('live:user:list')")
+    @PreAuthorize("@ss.hasPermi('live:issue:list')")
     @GetMapping("/list")
     public TableDataInfo list(LiveCouponUser liveCouponUser)
     {
@@ -51,7 +51,7 @@ public class LiveCouponUserController extends BaseController
     /**
      * 导出优惠券发放记录列表
      */
-    @PreAuthorize("@ss.hasPermi('live:user:export')")
+    @PreAuthorize("@ss.hasPermi('live:issue:export')")
     @Log(title = "优惠券发放记录", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(LiveCouponUser liveCouponUser)
@@ -64,7 +64,7 @@ public class LiveCouponUserController extends BaseController
     /**
      * 获取优惠券发放记录详细信息
      */
-    @PreAuthorize("@ss.hasPermi('live:user:query')")
+    @PreAuthorize("@ss.hasPermi('live:issue:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
@@ -74,7 +74,7 @@ public class LiveCouponUserController extends BaseController
     /**
      * 新增优惠券发放记录
      */
-    @PreAuthorize("@ss.hasPermi('live:user:add')")
+    @PreAuthorize("@ss.hasPermi('live:issue:add')")
     @Log(title = "优惠券发放记录", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody LiveCouponUser liveCouponUser)
@@ -85,7 +85,7 @@ public class LiveCouponUserController extends BaseController
     /**
      * 修改优惠券发放记录
      */
-    @PreAuthorize("@ss.hasPermi('live:user:edit')")
+    @PreAuthorize("@ss.hasPermi('live:issue:edit')")
     @Log(title = "优惠券发放记录", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody LiveCouponUser liveCouponUser)
@@ -96,7 +96,7 @@ public class LiveCouponUserController extends BaseController
     /**
      * 删除优惠券发放记录
      */
-    @PreAuthorize("@ss.hasPermi('live:user:remove')")
+    @PreAuthorize("@ss.hasPermi('live:issue:remove')")
     @Log(title = "优惠券发放记录", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)

+ 13 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveCouponController.java

@@ -193,6 +193,19 @@ public class LiveCouponController extends BaseController
         return liveCouponService.handleIsShowChange(payload);
     }
 
+
+    /**
+     * 查询优惠券列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:liveCoupon:list')")
+    @GetMapping("/listOn")
+    public TableDataInfo listOn(@RequestParam("liveId") Long liveId)
+    {
+        startPage();
+        List<LiveCoupon> list = liveCouponService.listOn(liveId);
+        return getDataTable(list);
+    }
+
     /**
      * 批量删除视频
      */

+ 20 - 0
fs-live-socket/src/main/java/com/fs/live/controller/LiveController.java

@@ -49,6 +49,7 @@ public class LiveController {
 	@Autowired
 	private WebSocketServer webSocketServer;
 
+
 	// 直播开播回调
 	@PostMapping("/startLiving")
 	public R checkLiving(HttpServletRequest request, @RequestBody  Map<String, String> params) {
@@ -118,6 +119,25 @@ public class LiveController {
 
 	}
 
+	@PostMapping("/videoUpload")
+	public R videoUpload(HttpServletRequest request, @RequestBody  Map<String, Object> params) {
+		log.info("请求参数:{}", params);
+		if(!params.containsKey("WorkflowExecution")) return R.error("参数错误");
+
+		LinkedHashMap<String,Object> result = (LinkedHashMap<String,Object>) params.get("WorkflowExecution");
+		String string = result.get("Object").toString();
+		videoService.updateFinishStatus("https://fs-1319721001.cos.ap-chongqing.myqcloud.com/" + string.replace(".mp4", ".m3u8"));
+
+		return R.ok();
+//		{app=200149.push.tlivecloud.com, appid=1319721001, appname=live, channel_id=673,
+//				errcode=1, errmsg=The push client actively stopped the push, event_time=1755571239,
+//				event_type=0, height=1080, idc_id=38, node=113.250.23.118, push_duration=1051237,
+//				sequence=721865018844564968, set_id=2, stream_id=673,
+//				stream_param=txSecret=A3EF362C9484D3D091C2E9B08C2C08CB&txTime=68A53145,
+//				user_ip=113.248.98.28, width=1920}
+
+	}
+
 
 
 }

+ 23 - 0
fs-live-socket/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.constant.LiveKeysConstant;
 import com.fs.live.config.ProductionWordFilter;
+import com.fs.live.mapper.LiveCouponMapper;
 import com.fs.live.websocket.auth.WebSocketConfigurator;
 import com.fs.live.websocket.bean.SendMsgVo;
 import com.fs.common.core.domain.R;
@@ -56,6 +57,8 @@ public class WebSocketServer {
     private final ILiveGoodsService liveGoodsService =  SpringUtils.getBean(ILiveGoodsService.class);
     private final ILiveUserFirstEntryService liveUserFirstEntryService =  SpringUtils.getBean(ILiveUserFirstEntryService.class);
     private final ILiveCouponIssueService liveCouponIssueService =  SpringUtils.getBean(ILiveCouponIssueService.class);
+    private final LiveCouponMapper liveCouponMapper = SpringUtils.getBean(LiveCouponMapper.class);
+
     // 直播间在线用户缓存
 //    private static final ConcurrentHashMap<Long, Integer> liveOnlineUsers = new ConcurrentHashMap<>();
 
@@ -526,6 +529,26 @@ public class WebSocketServer {
                 liveMsg.setCreateTime(now);
                 liveMsg.setUpdateTime(now);
                 liveMsgService.insertLiveMsg(liveMsg);
+            } else if (task.getTaskType() == 5L) {
+                msg.setCmd("coupon");
+                LiveCoupon liveCoupon = JSON.parseObject(task.getContent(), LiveCoupon.class);
+                if(liveCoupon.getStatus() != 1 ){
+                    log.error("优惠券状态已经关闭");
+                    return;
+                }
+                LiveCouponIssue liveCouponIssue = liveCouponIssueService.selectLiveCouponIssueByCouponId(liveCoupon.getCouponId());
+                LiveCouponIssueRelation relation = liveCouponMapper.selectCouponRelation(task.getLiveId(), liveCouponIssue.getId());
+                HashMap<String, Object> data = new HashMap<>();
+                data.put("liveId", task.getLiveId());
+                data.put("couponIssueId", liveCouponIssue.getId());
+                data.put("status", 1);
+                data.put("goodsId", relation.getGoodsId());
+                data.put("couponName", liveCoupon.getTitle());
+                data.put("couponPrice", liveCoupon.getCouponPrice());
+                data.put("useMinPrice", liveCoupon.getUseMinPrice());
+                data.put("couponTime", liveCoupon.getCouponTime());
+                msg.setData(JSON.toJSONString(data));
+                liveCouponMapper.updateChangeShow(task.getLiveId(), liveCouponIssue.getId());
             }
             msg.setStatus(1);
             broadcastMessage(task.getLiveId(), JSONObject.toJSONString(R.ok().put("data", msg)));

+ 31 - 0
fs-service-system/src/main/java/com/fs/company/mapper/CompanyMapper.java

@@ -3,6 +3,7 @@ package com.fs.company.mapper;
 import java.math.BigDecimal;
 import java.util.List;
 import com.fs.company.domain.Company;
+import com.fs.company.param.CompanyLiveShowParam;
 import com.fs.company.param.CompanyParam;
 import com.fs.company.vo.CompanyCrmVO;
 import com.fs.company.vo.CompanyVO;
@@ -122,4 +123,34 @@ public interface CompanyMapper
 
     @Select("select company_id,company_name from company where oms_code = #{omsCode}")
     List<Long> selectCompanyByOmsCode(@Param("omsCode") String omsCode);
+
+    @Select({"<script> " +
+            "select c.*,a.api_name as voice_api_name,u.user_name " +
+            "from company c left join company_voice_api a on a.api_id=c.voice_api_id left join company_user u on u.user_id=c.user_id " +
+            "where is_del=0 " +
+            "<if test = 'maps.liveShow != null  '> " +
+            "and c.live_show = #{maps.liveShow}" +
+            "</if>" +
+            "<if test = 'maps.companyName != null and  maps.companyName !=\"\"     '> " +
+            "and c.company_name like CONCAT('%',#{maps.companyName},'%') " +
+            "</if>" +
+
+            "<if test = 'maps.status != null   '> " +
+            "and c.status = #{maps.status}" +
+            "</if>" +
+            "order by c.company_id desc " +
+            "</script>"})
+    List<CompanyVO> liveShowList(@Param("maps")CompanyParam param);
+
+    @Update({"<script> " +
+            "update company set live_show = #{maps.liveShow} where " +
+            "company_id in " +
+            "<foreach collection='maps.ids' item='ids' open='(' separator=',' close=')'>",
+            " #{ids} ",
+            "</foreach> </script>"
+    })
+    void batchUpdateLiveShow(@Param("maps") CompanyLiveShowParam param);
+
+    @Select("select company_id from company where live_show=1")
+    List<Long> selectLiveShowCompanyId();
 }

+ 15 - 0
fs-service-system/src/main/java/com/fs/company/param/CompanyLiveShowParam.java

@@ -0,0 +1,15 @@
+package com.fs.company.param;
+
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CompanyLiveShowParam
+{
+
+
+    private List<Long> ids;
+    private Integer liveShow;
+}

+ 9 - 0
fs-service-system/src/main/java/com/fs/company/param/CompanyParam.java

@@ -12,6 +12,7 @@ public class CompanyParam
     private Long companyId;
     private Integer status;
     private String phonenumber;
+    private Integer liveShow;
 
     public String getCompanyName() {
         return companyName;
@@ -44,4 +45,12 @@ public class CompanyParam
     public void setPhonenumber(String phonenumber) {
         this.phonenumber = phonenumber;
     }
+
+    public Integer getLiveShow() {
+        return liveShow;
+    }
+
+    public void setLiveShow(Integer liveShow) {
+        this.liveShow = liveShow;
+    }
 }

+ 5 - 0
fs-service-system/src/main/java/com/fs/company/service/ICompanyService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.fs.common.core.domain.R;
 import com.fs.company.domain.Company;
+import com.fs.company.param.CompanyLiveShowParam;
 import com.fs.company.param.CompanyParam;
 import com.fs.company.vo.CompanyCrmVO;
 import com.fs.company.vo.CompanyVO;
@@ -102,4 +103,8 @@ public interface ICompanyService
     void addCompanyTuiLiveMoney(LiveOrder order);
 
     void subLiveCompanyMoney(LiveOrder order);
+
+    List<CompanyVO> liveShowList(CompanyParam param);
+
+    void batchUpdateLiveShow(CompanyLiveShowParam param);
 }

+ 17 - 0
fs-service-system/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.company.service.impl;
 
 import java.math.BigDecimal;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -9,6 +10,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.utils.DateUtils;
 import com.fs.company.domain.*;
 import com.fs.company.mapper.*;
+import com.fs.company.param.CompanyLiveShowParam;
 import com.fs.company.param.CompanyParam;
 import com.fs.company.service.ICompanyProfitService;
 import com.fs.company.vo.CompanyCrmVO;
@@ -16,6 +18,7 @@ import com.fs.company.vo.CompanyVO;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.mapper.LiveOrderMapper;
 import com.fs.live.service.ILiveOrderService;
+import com.fs.live.service.ILiveService;
 import com.fs.store.config.StoreConfig;
 import com.fs.store.domain.FsStoreOrder;
 import com.fs.store.domain.FsStorePayment;
@@ -67,6 +70,20 @@ public class CompanyServiceImpl implements ICompanyService
     private ICompanyProfitService companyProfitService;
     @Autowired
     private LiveOrderMapper liveOrderMapper;
+    @Autowired
+    private ILiveService liveService;
+
+
+    @Override
+    public List<CompanyVO> liveShowList(CompanyParam param) {
+        return companyMapper.liveShowList(param);
+    }
+
+    @Override
+    public void batchUpdateLiveShow(CompanyLiveShowParam param) {
+        companyMapper.batchUpdateLiveShow(param);
+        liveService.asyncToCache();
+    }
 
 
     /**

+ 1 - 0
fs-service-system/src/main/java/com/fs/company/vo/CompanyVO.java

@@ -73,6 +73,7 @@ public class CompanyVO implements Serializable
     private Integer limitUserCount;
 
     private Integer voiceCallerNumber;
+    private Integer liveShow;
 
 
 

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

@@ -41,4 +41,6 @@ public class LiveVideo extends BaseEntity {
     /** 排序号 */
     @Excel(name = "排序号")
     private Long sort;
+    @Excel(name = "转码状态")
+    private Integer finishStatus;
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveCouponIssueMapper.java

@@ -75,4 +75,7 @@ public interface LiveCouponIssueMapper
 
     @Insert("insert into live_coupon_issue_relation(live_id,coupon_issue_id,is_show,goods_id) values(#{liveId},#{couponIssueId},#{isShow},#{goodsId})")
     void insertLiveCouponIssueRelation(LiveCouponIssueRelation liveCouponIssueRelation);
+
+    @Select("select * from live_coupon_issue where coupon_id= #{couponId}")
+    LiveCouponIssue selectLiveCouponIssueByCouponId(@Param("couponId") Long couponId);
 }

+ 17 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveCouponMapper.java

@@ -108,4 +108,21 @@ public interface LiveCouponMapper
 
     @Select("select lci.* from live_coupon_issue lci left join live_coupon_issue_relation lcir on lci.id=lcir.coupon_issue_id where lcir.live_id = #{liveId} and lci.id = #{couponId}")
     LiveCouponIssue selectLiveCouponIssueByLiveIdAndCouponId(@Param("liveId")Long liveId,@Param("couponId") Long couponId);
+
+    @Select("select lc.*,lci.id,lcir.is_show,lcir.goods_id,fsp.product_name,fsp.image " +
+            "from live_coupon_issue_relation lcir left join live_coupon_issue lci " +
+            "left join live_coupon lc on lc.coupon_id=lci.coupon_id on lci.id = lcir.coupon_issue_id  " +
+            "left join live_goods lg on lg.goods_id = lcir.goods_id " +
+            "left join fs_store_product fsp on lg.product_id = fsp.product_id " +
+            "where lcir.live_id = #{liveId} and lcir.goods_id is not null")
+    List<LiveCoupon> listOn(@Param("liveId") Long liveId);
+
+    @Update("update live_coupon_issue_relation set is_show = case WHEN coupon_issue_id = #{couponId} THEN 1 else 0 end where live_id = #{liveId}")
+    void updateChangeShow(@Param("liveId")Long liveId,@Param("couponId") Long couponId);
+
+    @Select("select * from live_coupon_issue_relation where live_id = #{liveId} and coupon_issue_id = #{couponId}")
+    LiveCouponIssueRelation selectCouponRelation(@Param("liveId")Long liveId,@Param("couponId") Long couponId);
+
+    @Select("select * from live_coupon_issue_relation where live_id = #{liveId}")
+    List<LiveCouponIssueRelation> selectCouponRelationByLiveId(@Param("liveId") Long liveId);
 }

+ 5 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveMapper.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -129,4 +130,8 @@ public interface LiveMapper
     Integer updateLiveIsAudit(Live live);
 
     List<Live> selectReadyStartLiveList();
+
+    List<Live> liveShowList(@Param("companyIds") List<Long> companyIds);
+
+    List<Live> selectLiveShowReadyStartLiveList(@Param("companyIds") List<Long> companyIds);
 }

+ 4 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveVideoMapper.java

@@ -4,6 +4,7 @@ package com.fs.live.mapper;
 import com.fs.live.domain.LiveVideo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
 
@@ -89,4 +90,7 @@ public interface LiveVideoMapper
 
     @Select("select * from live_video")
     List<LiveVideo> selectByAll();
+
+    @Update("update live_video set finish_status = 1 where video_url = #{fileName}")
+    void updateFinishStatus(@Param("fileName") String fileName);
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveCouponIssueService.java

@@ -63,4 +63,6 @@ public interface ILiveCouponIssueService
     List<LiveCouponIssue> selectLiveCouponIssueUserByCouponPO(CouponPO coupon);
 
     List<LiveCouponIssue> curCoupon(CouponPO coupon);
+
+    LiveCouponIssue selectLiveCouponIssueByCouponId(Long id);
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveCouponService.java

@@ -86,4 +86,6 @@ public interface ILiveCouponService
     R userCouponList(CouponPO coupon);
 
     R curCoupon(CouponPO coupon);
+
+    List<LiveCoupon> listOn(Long liveId);
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveCouponUserService.java

@@ -1,6 +1,8 @@
 package com.fs.live.service;
 
 import java.util.List;
+
+import com.fs.live.domain.LiveCoupon;
 import com.fs.live.domain.LiveCouponUser;
 import com.fs.live.param.CouponPO;
 
@@ -63,4 +65,5 @@ public interface ILiveCouponUserService
     List<LiveCouponUser> selectLiveCouponUserByCouponPO(CouponPO coupon);
 
     List<LiveCouponUser> curCoupon(CouponPO coupon);
+
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveVideoService.java

@@ -84,4 +84,6 @@ public interface ILiveVideoService
     List<LiveVideo> selectLiveVideosByLiveId(Long existLiveId);
 
     LiveVideo selectLiveVideoByLiveIdAndType(Long id, int i);
+
+    void updateFinishStatus(String string);
 }

+ 31 - 5
fs-service-system/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java

@@ -8,17 +8,16 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
-import com.fs.live.domain.Live;
-import com.fs.live.domain.LiveAutoTask;
-import com.fs.live.domain.LiveLotteryConf;
-import com.fs.live.domain.LiveRedConf;
+import com.fs.live.domain.*;
 import com.fs.live.mapper.*;
 import com.fs.live.param.LiveLotteryProduct;
 import com.fs.live.service.ILiveAutoTaskService;
+import com.fs.live.service.ILiveCouponService;
 import com.fs.live.service.ILiveGoodsService;
 import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveLotteryConfVo;
@@ -51,6 +50,10 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
     private LiveLotteryConfMapper liveLotteryConfMapper;
     @Autowired
     private LiveLotteryProductConfMapper lotteryProductConfMapper;
+    @Autowired
+    private LiveCouponMapper liveCouponMapper;
+    @Autowired
+    private LiveCouponIssueMapper liveCouponIssueMapper;
 
     /**
      * 查询直播间自动化任务配置
@@ -138,7 +141,18 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
             baseMapper.insertLiveAutoTask(liveAutoTask);
         } else if(liveAutoTask.getTaskType() == 3L){
             baseMapper.insertLiveAutoTask(liveAutoTask);
-
+        } else if (liveAutoTask.getTaskType() == 5L) {
+            // 自动优惠券
+            LiveCoupon liveCoupon = liveCouponMapper.selectLiveCouponById(Long.valueOf(liveAutoTask.getContent()));
+            if(liveCoupon == null) return R.error("优惠券不存在");
+            LiveCouponIssue liveCouponIssue = liveCouponIssueMapper.selectLiveCouponIssueByCouponId(liveCoupon.getCouponId());
+            if(liveCouponIssue == null)return R.error("优惠券未发布");
+            LiveCouponIssueRelation liveCouponIssueRelation = liveCouponMapper.selectCouponRelation(liveAutoTask.getLiveId(),liveCouponIssue.getId());
+            if(liveCouponIssueRelation == null) return R.error("优惠券尚未添加在直播间");
+            if(ObjectUtil.isEmpty(liveCouponIssueRelation.getGoodsId())) return R.error("未绑定商品,无法制定自动化任务!");
+            liveCoupon.setGoodsId(liveCouponIssueRelation.getGoodsId());
+            liveAutoTask.setContent(JSON.toJSONString(liveCoupon));
+            baseMapper.insertLiveAutoTask(liveAutoTask);
         } else {
             return R.error("任务类型错误");
         }
@@ -240,6 +254,18 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
             return baseMapper.updateLiveAutoTask(liveAutoTask);
         } else if(liveAutoTask.getTaskType() == 3L){
             return baseMapper.updateLiveAutoTask(liveAutoTask);
+        }else if( liveAutoTask.getTaskType() == 5L){
+            // 自动优惠券
+            LiveCoupon liveCoupon = liveCouponMapper.selectLiveCouponById(Long.valueOf(liveAutoTask.getContent()));
+            if(liveCoupon == null) return -1;
+            LiveCouponIssue liveCouponIssue = liveCouponIssueMapper.selectLiveCouponIssueByCouponId(liveCoupon.getCouponId());
+            if(liveCouponIssue == null)return -1;
+            LiveCouponIssueRelation liveCouponIssueRelation = liveCouponMapper.selectCouponRelation(liveAutoTask.getLiveId(),liveCouponIssue.getId());
+            if(liveCouponIssueRelation == null) return -1;
+            if(ObjectUtil.isEmpty(liveCouponIssueRelation.getGoodsId())) return -1;
+            liveCoupon.setGoodsId(liveCouponIssueRelation.getGoodsId());
+            liveAutoTask.setContent(JSON.toJSONString(liveCoupon));
+            return baseMapper.updateLiveAutoTask(liveAutoTask);
         } else {
             return -1;
         }

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

@@ -105,4 +105,9 @@ public class LiveCouponIssueServiceImpl implements ILiveCouponIssueService
     public List<LiveCouponIssue> curCoupon(CouponPO coupon) {
         return liveCouponIssueMapper.curCoupon(coupon);
     }
+
+    @Override
+    public LiveCouponIssue selectLiveCouponIssueByCouponId(Long couponId) {
+        return liveCouponIssueMapper.selectLiveCouponIssueByCouponId(couponId);
+    }
 }

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

@@ -259,5 +259,10 @@ public class LiveCouponServiceImpl implements ILiveCouponService
         return R.ok().put("data", list);
     }
 
+    @Override
+    public List<LiveCoupon> listOn(Long liveId) {
+        return liveCouponMapper.listOn(liveId);
+    }
+
 
 }

+ 25 - 2
fs-service-system/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -14,6 +14,7 @@ import com.fs.common.exception.BaseException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.bean.BeanUtils;
+import com.fs.company.mapper.CompanyMapper;
 import com.fs.live.domain.*;
 import com.fs.live.mapper.*;
 import com.fs.live.param.LiveLotteryProduct;
@@ -103,6 +104,11 @@ public class LiveServiceImpl implements ILiveService
 
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private CompanyMapper companyMapper;
+    @Autowired
+    private LiveCouponMapper liveCouponMapper;
+
     /**
      * 查询直播
      *
@@ -421,10 +427,11 @@ public class LiveServiceImpl implements ILiveService
 
     @Override
     public List<Live> liveList() {
-        List<Live> livesList = baseMapper.liveList();
+        List<Long> companyIds = companyMapper.selectLiveShowCompanyId();
+        List<Live> livesList = baseMapper.liveShowList(companyIds);
         try {
             // 查询准备开播的直播间
-            livesList.addAll(baseMapper.selectReadyStartLiveList());
+            livesList.addAll(baseMapper.selectLiveShowReadyStartLiveList(companyIds));
         }catch (Exception e){
             log.error("查询准备开播的直播间异常", e);
         }
@@ -739,6 +746,7 @@ public class LiveServiceImpl implements ILiveService
         List<LiveAutoTask> goodsTaskList = liveAutoTasksList.stream().filter(liveAutoTask -> liveAutoTask.getTaskType() == 1L).collect(Collectors.toList());
         List<LiveAutoTask> redTaskList = liveAutoTasksList.stream().filter(liveAutoTask -> liveAutoTask.getTaskType() == 2L).collect(Collectors.toList());
         List<LiveAutoTask> lotteryTaskList = liveAutoTasksList.stream().filter(liveAutoTask -> liveAutoTask.getTaskType() == 4L).collect(Collectors.toList());
+        List<LiveAutoTask> couponTaskList = liveAutoTasksList.stream().filter(liveAutoTask -> liveAutoTask.getTaskType() == 5L).collect(Collectors.toList());
         List<LiveAutoTask> addList = new ArrayList<>();
         if (!barrageTask.isEmpty()) {
             for (LiveAutoTask liveAutoTask : barrageTask) {
@@ -840,6 +848,21 @@ public class LiveServiceImpl implements ILiveService
                 // 优惠券
                 liveCouponIssueRelations.stream().filter(relation -> liveGoods.getGoodsId().equals(relation.getGoodsId())).findFirst().ifPresent(liveCouponIssueRelation -> liveCouponIssueRelation.setGoodsId(liveGoodsEntity.getGoodsId()));
                 LiveAutoTask liveAutoTask = goodsTaskList.stream().filter(item -> parseIdFromContent(item.getContent(), "goodsId").equals(liveGoods.getGoodsId())).findFirst().orElse(null);
+                // 优惠券定时任务
+                LiveAutoTask couponTask = couponTaskList.stream().filter(item -> parseIdFromContent(item.getContent(), "goodsId").equals(liveGoods.getGoodsId())).findFirst().orElse(null);
+                if (couponTask != null) {
+                    LiveAutoTask tempTask = new LiveAutoTask();
+                    BeanUtils.copyBeanProp(tempTask, couponTask);
+                    tempTask.setId(null);
+                    tempTask.setLiveId(newLiveId);
+                    tempTask.setCreateTime(now);
+                    tempTask.setUpdateTime(now);
+                    tempTask.setFinishStatus(0L);
+                    LiveCoupon liveCoupon = JSON.parseObject(tempTask.getContent(), LiveCoupon.class);
+                    liveCoupon.setGoodsId(liveGoodsEntity.getGoodsId());
+                    tempTask.setContent(JSON.toJSONString(liveCoupon));
+                    liveAutoTaskService.directInsertLiveAutoTask(tempTask);
+                }
                 if(liveAutoTask == null) continue;
                 liveGoods.setGoodsId(liveGoodsEntity.getGoodsId());
                 LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();

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

@@ -77,6 +77,7 @@ public class LiveVideoServiceImpl implements ILiveVideoService
     public int insertLiveVideo(LiveVideo liveVideo)
     {
         // 直播ID为-1,则新增 直播视频库
+        liveVideo.setFinishStatus(0);
         if (liveVideo.getLiveId() == -1) {
             liveVideo.setCreateTime(DateUtils.getNowDate());
             return liveVideoMapper.insertLiveVideo(liveVideo);
@@ -174,4 +175,9 @@ public class LiveVideoServiceImpl implements ILiveVideoService
         return null;
     }
 
+    @Override
+    public void updateFinishStatus(String string) {
+        liveVideoMapper.updateFinishStatus(string);
+    }
+
 }

+ 44 - 0
fs-service-system/src/main/resources/mapper/live/LiveMapper.xml

@@ -299,5 +299,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </update>
 
+    <select id="liveShowList"  resultMap="LiveResult">
+        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,c.company_name,b.file_size
+        from live
+                 a
+                 left join live_video b on a.live_id = b.live_id
+                 left join company c on a.company_id = c.company_id
+        where 1=1 and a.is_del = 0 and a.is_audit = 1 and a.is_show = 1 and a.status in (2,4) and b.video_type in (1,2)
+          and (
+              <if test="companyIds != null and companyIds.size() > 0">
+                  a.company_id in
+                  <foreach collection="companyIds" item="id" open="(" separator="," close=")">
+                      #{id}
+                  </foreach>
+                  or
+              </if>
+               a.company_id is null)
+        order by create_time desc
+    </select>
+
+    <select id="selectLiveShowReadyStartLiveList"  resultMap="LiveResult">
+        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,c.company_name,b.file_size
+        from live
+                 a
+                 left join live_video b on a.live_id = b.live_id
+                 left join company c on a.company_id = c.company_id
+        where 1=1 and a.is_del = 0 and a.is_audit = 1 and a.is_show = 1 and a.status in (1) and b.video_type in (1,2)
+          and a.start_time &lt;= NOW() + INTERVAL 5 MINUTE
+          and a.start_time >= NOW()
+        and (
+        <if test="companyIds != null and companyIds.size() > 0">
+            a.company_id in
+            <foreach collection="companyIds" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+            or
+        </if>
+             a.company_id is null)
+        order by create_time desc
+    </select>
+
 
 </mapper>

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

@@ -17,10 +17,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="duration"    column="duration"    />
         <result property="remark"    column="remark"    />
         <result property="fileSize"    column="file_size"    />
+        <result property="finishStatus"    column="finish_status"    />
     </resultMap>
 
     <sql id="selectLiveVideoVo">
-        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration,file_size from live_video
+        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration,file_size,finish_status from live_video
     </sql>
 
     <select id="selectLiveVideoList" parameterType="LiveVideo" resultMap="LiveVideoResult">
@@ -31,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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>
+            <if test="finishStatus != null "> and finish_status  = #{finishStatus}</if>
         </where>
     </select>
 
@@ -57,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">remark,</if>
             <if test="duration != null">duration,</if>
             <if test="fileSize != null">file_size,</if>
+            <if test="finishStatus != null">finish_status,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -70,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">#{remark},</if>
             <if test="duration != null">#{duration},</if>
             <if test="fileSize != null">#{fileSize},</if>
+            <if test="finishStatus != null">#{finishStatus},</if>
          </trim>
     </insert>
 
@@ -87,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="remark != null">remark = #{remark},</if>
             <if test="fileSize != null">file_size = #{fileSize},</if>
+            <if test="finishStatus != null">finish_status = #{finishStatus},</if>
         </trim>
         where video_id = #{videoId}
     </update>