Selaa lähdekoodia

直播代码 websocket添加状态(主要用于直播信息传递

yuhongqi 1 kuukausi sitten
vanhempi
commit
e98ab82a8d
41 muutettua tiedostoa jossa 752 lisäystä ja 80 poistoa
  1. 1 2
      fs-admin/src/main/java/com/fs/live/controller/LiveLotteryConfController.java
  2. 96 0
      fs-company/src/main/java/com/fs/company/controller/live/LiveController.java
  3. 1 2
      fs-company/src/main/java/com/fs/company/controller/live/LiveLotteryConfController.java
  4. 0 1
      fs-company/src/main/java/com/fs/company/controller/live/LiveVideoController.java
  5. 34 0
      fs-live-app/src/main/java/com/fs/app/controller/LiveController.java
  6. 69 25
      fs-live-app/src/main/java/com/fs/app/task/Task.java
  7. 4 0
      fs-live-app/src/main/java/com/fs/app/websocket/service/WebSocketServer.java
  8. 2 2
      fs-service/src/main/java/com/fs/his/mapper/FsStoreProductMapper.java
  9. 5 2
      fs-service/src/main/java/com/fs/live/domain/Live.java
  10. 39 0
      fs-service/src/main/java/com/fs/live/domain/LiveCompanyCode.java
  11. 4 0
      fs-service/src/main/java/com/fs/live/domain/LiveGoods.java
  12. 8 0
      fs-service/src/main/java/com/fs/live/domain/LiveUserFirstEntry.java
  13. 5 0
      fs-service/src/main/java/com/fs/live/domain/LiveWatchUser.java
  14. 5 0
      fs-service/src/main/java/com/fs/live/mapper/LiveAutoTaskMapper.java
  15. 66 0
      fs-service/src/main/java/com/fs/live/mapper/LiveCompanyCodeMapper.java
  16. 4 4
      fs-service/src/main/java/com/fs/live/mapper/LiveGoodsMapper.java
  17. 2 0
      fs-service/src/main/java/com/fs/live/mapper/LiveLotteryConfMapper.java
  18. 4 0
      fs-service/src/main/java/com/fs/live/mapper/LiveRedConfMapper.java
  19. 2 2
      fs-service/src/main/java/com/fs/live/mapper/LiveWatchUserMapper.java
  20. 16 0
      fs-service/src/main/java/com/fs/live/param/LiveReplayParam.java
  21. 0 4
      fs-service/src/main/java/com/fs/live/param/LotteryPO.java
  22. 2 0
      fs-service/src/main/java/com/fs/live/service/ILiveAutoTaskService.java
  23. 63 0
      fs-service/src/main/java/com/fs/live/service/ILiveCompanyCodeService.java
  24. 3 1
      fs-service/src/main/java/com/fs/live/service/ILiveLotteryConfService.java
  25. 5 0
      fs-service/src/main/java/com/fs/live/service/ILiveRedConfService.java
  26. 10 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java
  27. 99 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveCompanyCodeServiceImpl.java
  28. 3 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveGoodsServiceImpl.java
  29. 13 4
      fs-service/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java
  30. 5 4
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  31. 15 5
      fs-service/src/main/java/com/fs/live/service/impl/LiveRedConfServiceImpl.java
  32. 20 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java
  33. 1 1
      fs-service/src/main/java/com/fs/live/service/impl/LiveVideoServiceImpl.java
  34. 1 0
      fs-service/src/main/java/com/fs/live/vo/LiveGoodsVo.java
  35. 81 0
      fs-service/src/main/resources/mapper/live/LiveCompanyCodeMapper.xml
  36. 16 9
      fs-service/src/main/resources/mapper/live/LiveGoodsMapper.xml
  37. 8 0
      fs-service/src/main/resources/mapper/live/LiveLotteryConfMapper.xml
  38. 15 5
      fs-service/src/main/resources/mapper/live/LiveMapper.xml
  39. 2 0
      fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml
  40. 6 0
      fs-service/src/main/resources/mapper/live/LiveRedConfMapper.xml
  41. 17 7
      fs-service/src/main/resources/mapper/live/LiveUserFirstEntryMapper.xml

+ 1 - 2
fs-admin/src/main/java/com/fs/live/controller/LiveLotteryConfController.java

@@ -91,8 +91,7 @@ public class LiveLotteryConfController extends BaseController
     @PutMapping
     public R edit(@RequestBody LiveLotteryConf liveLotteryConf)
     {
-        liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf);
-        return R.ok(liveLotteryConf.getLotteryStatus());
+        return liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf);
     }
 
     /**

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

@@ -1,25 +1,48 @@
 package com.fs.company.controller.live;
 
+import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.exception.file.OssException;
+import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.http.HttpUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.domain.CompanyUser;
+import com.fs.his.domain.FsPayConfig;
+import com.fs.his.utils.HttpUtil;
+import com.fs.live.domain.LiveCompanyCode;
+import com.fs.live.service.ILiveCompanyCodeService;
 import com.fs.live.vo.LiveListVo;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.security.SecurityUtils;
 import com.fs.framework.service.TokenService;
 import com.fs.live.domain.Live;
 import com.fs.live.service.ILiveService;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.oss.CloudStorageService;
+import com.fs.system.oss.OSSFactory;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServlet;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -37,6 +60,8 @@ public class LiveController extends BaseController
     private ILiveService liveService;
     @Autowired
     private TokenService tokenService;
+    @Autowired
+    private ILiveCompanyCodeService liveCompanyCodeService;
 
     /**
      * 查询直播列表
@@ -258,4 +283,75 @@ public class LiveController extends BaseController
         live.setCompanyId(user.getCompanyId());
         live.setCompanyUserId(user.getUserId());
     }
+
+    @ApiOperation("查询微信urlScheme")
+    @GetMapping("/getAppletScheme")
+    public R getAppletScheme(@RequestParam(value = "cardId") Long cardId) {
+        try {
+            String appId = "123";
+            String secret = "123";
+            String rspStr = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/token", "grant_type=client_credential&" + "appid=" + appId + "&secret=" + secret);
+            JSONObject obj = JSONObject.parseObject(rspStr);
+            String access_token = obj.getString("access_token");
+            JSONObject jsonObject = new JSONObject();
+            JSONObject jump_wxaObj = new JSONObject();
+            jump_wxaObj.put("path", "/pages_company/card");
+            jump_wxaObj.put("query", "id=" + cardId);
+            jsonObject.put("jump_wxa", jump_wxaObj);
+            jsonObject.put("is_expire", false);
+            String paramStr = jsonObject.toJSONString();
+            String postStr = HttpUtils.sendPost("https://api.weixin.qq.com/wxa/generatescheme?access_token=" + access_token, paramStr);
+            obj = JSONObject.parseObject(postStr);
+            //response.addHeader("Access-Control-Allow-Origin", "*");
+            return R.ok().put("result", obj);
+        } catch (Exception e) {
+            return R.error("操作失败");
+        }
+    }
+
+    @ApiOperation("生成微信小程序码")
+    @GetMapping("/getWxaCodeUnLimit")
+    public R getWxaCodeUnLimit(@RequestParam(value = "liveId") Long liveId) {
+        String url="https://api.weixin.qq.com/cgi-bin/stable_token";
+        HashMap<String, String> map = new HashMap<>();
+        map.put("grant_type","client_credential");
+        // 芳华惠选
+        map.put("appid","wx503cf8ab31f83dd4");
+        map.put("secret","1ba1972363889dcb4a37ecb685744435");
+        String accessToken = HttpUtil.endApi(url, null, map);
+        // 创建Gson对象
+        Gson gson = new Gson();
+        // 将JSON字符串解析为Java对象
+        Map<String, String> accessTokenMap  = gson.fromJson(accessToken, new TypeToken<Map<String, Object>>(){}.getType());
+        String codeUrl="https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessTokenMap.get("access_token");
+        HashMap<String, String> jsonMap = new HashMap<>();
+        jsonMap.put("page","pages/auth/login");
+        CompanyUser user = SecurityUtils.getLoginUser().getUser();
+        String scene = "a="+ liveId+"&b="+user.getCompanyId()+"&c="+user.getUserId();
+        jsonMap.put("scene",scene);
+        //正式版为 "release",体验版为 "trial",开发版为 "develop"
+        jsonMap.put("env_version","trial");
+        byte[] bytes = HttpUtil.getWechatQrcodeByHttpURL(codeUrl, jsonMap);
+        if(bytes.length == 0) return R.error("生成二维码失败");
+        if (bytes.length > 0 && bytes.length < 500) {
+            String errorCode = new String(bytes, StandardCharsets.UTF_8);
+            logger.error(errorCode);
+            return R.error("生成二维码失败");
+        }
+        // 保存
+        String saveUrl = OSSFactory.build().uploadSuffix(bytes, ".png");
+        Date nowDate = DateUtils.getNowDate();
+        LiveCompanyCode exist = liveCompanyCodeService.selectByLiveIdAndUser(liveId, user.getCompanyId(), user.getUserId());
+        if (exist == null) {
+            exist = new LiveCompanyCode();
+            exist.setLiveId(liveId);
+            exist.setCompanyId(user.getCompanyId());
+            exist.setCompanyUserId(user.getUserId());
+            exist.setCreateTime(nowDate);
+        }
+        exist.setUpdateTime(nowDate);
+        exist.setLiveCodeUrl(saveUrl);
+        liveCompanyCodeService.saveOrUpdate(exist);
+        return R.ok().put("data", exist);
+    }
 }

+ 1 - 2
fs-company/src/main/java/com/fs/company/controller/live/LiveLotteryConfController.java

@@ -83,8 +83,7 @@ public class LiveLotteryConfController extends BaseController
     @PutMapping
     public R edit(@RequestBody LiveLotteryConf liveLotteryConf)
     {
-        liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf);
-        return R.ok(liveLotteryConf.getLotteryStatus());
+       return liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf);
     }
 
     /**

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

@@ -65,7 +65,6 @@ public class LiveVideoController extends BaseController
     /**
      * 获取直播视频详细信息
      */
-    @PreAuthorize("@ss.hasPermi('live:liveVideo:query')")
     @GetMapping(value = "/liveVideoByLiveId/{liveId}")
     public AjaxResult getLiveVideoByLiveId(@PathVariable("liveId") Long liveId)
     {

+ 34 - 0
fs-live-app/src/main/java/com/fs/app/controller/LiveController.java

@@ -15,6 +15,7 @@ import com.fs.common.core.domain.BaseEntity;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.bean.BeanUtils;
 import com.fs.his.service.IFsUserService;
@@ -59,6 +60,9 @@ public class LiveController extends AppBaseController {
 	@Autowired
 	private ILiveGoodsService liveGoodsService;
 
+	@Autowired
+	private ILiveVideoService videoService;
+
 
 
 	@ApiOperation("直播封面信息")
@@ -141,6 +145,7 @@ public class LiveController extends AppBaseController {
 	}
 
 
+	// 直播开播回调
 	@PostMapping("/startLiving")
 	public R checkLiving(HttpServletRequest request, @RequestBody  Map<String, String> params) {
 		log.info("请求参数:{}", params);
@@ -156,6 +161,7 @@ public class LiveController extends AppBaseController {
 //		stream_param=txSecret=6E89AECCA08DBEE82E7F5870BCED7132&txTime=688ACD21, user_ip=125.80.218.101, width=1920}
 	}
 
+	// 直播结束回调
 	@PostMapping("/endLiving")
 	public R endLiving(HttpServletRequest request, @RequestBody  Map<String, String> params) {
 		log.info("请求参数:{}", params);
@@ -179,6 +185,34 @@ public class LiveController extends AppBaseController {
 
 	}
 
+	// 直播录制文件回调 腾讯云 cos桶 fs
+	@PostMapping("/liveReplayFile")
+	public R liveReplayFile(HttpServletRequest request, @RequestBody  Map<String, String> params) {
+		log.info("请求参数:{}", params);
+		Long liveId = Long.valueOf(params.get("stream_id"));
+		LiveVideo liveVideo = new LiveVideo();
+		LiveVideo exist = videoService.selectLiveVideoByLiveId(liveId);
+		if (exist != null) {
+			liveVideo = exist;
+		}
+		Date nowDate = DateUtils.getNowDate();
+		liveVideo.setLiveId(liveId);
+		liveVideo.setVideoUrl(params.get("video_url"));
+		liveVideo.setVideoType(2);
+		liveVideo.setDuration(Long.valueOf(params.get("duration")));
+		liveVideo.setCreateTime(nowDate);
+		liveVideo.setUpdateTime(nowDate);
+		videoService.saveOrUpdate(liveVideo);
+		return R.ok();
+//		{app=200149.push.tlivecloud.com, appid=1319721001, appname=live,
+//				callback_ext={"video_codec":"h264","session_id":"1755326625589574166","resolution":"1920x1080"},
+//			channel_id=774, duration=137, end_time=1757387736, end_time_usec=476103, event_type=100, file_format=mp4,
+//					file_id=1319721001_d69054948de44655b465aaf725cafc1c, file_size=45806289, media_start_time=80, record_bps=0,
+//				record_file_id=1319721001_d69054948de44655b465aaf725cafc1c, record_temp_id=1595756, start_time=1757387600, start_time_usec=942579,
+//				stream_id=774, stream_param=txSecret=CBF1E86FB1AD58B9CC25941F6B9DA854&txTime=68C0E304, task_id=1755326625589574166, video_id=1319721001_05396a7c47914b40aa9ffefcb0ea4626,
+//				video_url=http://fs-1319721001.cos.ap-chongqing.myqcloud.com/origin/200149.push.tlivecloud.com/live/774/1755326625589574166-6a9899ea95be4e89be0eeb30cf458579/2025-09-09-11-13-20.mp4}
+
+	}
 	@GetMapping("/currentActivities")
 	@Transactional
 	@Login

+ 69 - 25
fs-live-app/src/main/java/com/fs/app/task/Task.java

@@ -13,6 +13,7 @@ import com.fs.common.utils.spring.SpringUtils;
 import com.fs.his.service.IFsUserService;
 import com.fs.live.domain.*;
 import com.fs.live.mapper.LiveLotteryRegistrationMapper;
+import com.fs.live.param.LiveReplayParam;
 import com.fs.live.service.*;
 import com.fs.live.vo.LiveLotteryConfVo;
 import com.fs.live.vo.LiveLotteryProductListVo;
@@ -56,35 +57,50 @@ public class Task {
     private ILiveUserLotteryRecordService liveUserLotteryRecordService;
     @Autowired
     private LiveLotteryRegistrationMapper liveLotteryRegistrationMapper;
+    @Autowired
+    private ILiveRedConfService liveRedConfService;
 
     @Scheduled(cron = "0 0/1 * * * ?")
     //public void selectSopUserLogsListByTime() {
     public void updateLiveStatusByTime() {
-        LocalDateTime now = LocalDateTime.now();
-        List<Live> list = liveService.list(new QueryWrapper<Live>().ne("status", 3).eq("live_type", 2).eq("is_audit", 1));
-        List<Long> liveIdLists = list.stream().map(Live::getLiveId).collect(Collectors.toList());
-        List<LiveAutoTask> liveAutoTasks = liveAutoTaskService.selectLiveAutoTaskByLiveIds(liveIdLists);
+        List<Live> list = liveService.list(new QueryWrapper<Live>().ne("status", 3).in("live_type", 2, 3).eq("is_audit", 1));
         if (list.isEmpty())
             return;
+        List<Long> liveIdLists = list.stream().map(Live::getLiveId).collect(Collectors.toList());
+        List<LiveAutoTask> liveAutoTasks = liveAutoTaskService.selectLiveAutoTaskByLiveIds(liveIdLists);
         List<Live> activeLiveList = new ArrayList<>();
+        LocalDateTime now = LocalDateTime.now();
         list.forEach(live -> {
-            if (live.getFinishTime() == null) {
-                if (now.isAfter(live.getStartTime())){
-                    live.setStatus(2);
-                    activeLiveList.add( live);
-                } else if (now.isBefore(live.getStartTime())) {
-                    live.setStatus(1);
+            if (live.getLiveType() != 3) {
+                if (live.getFinishTime() == null) {
+                    if (now.isAfter(live.getStartTime().minusSeconds(2L))){
+                        live.setStatus(2);
+                        activeLiveList.add( live);
+                    } else if (now.isBefore(live.getStartTime())) {
+                        live.setStatus(1);
+                    }
+                } else {
+                    if (now.isAfter(live.getStartTime().minusSeconds(2L)) && now.isBefore(live.getFinishTime())) {
+                        live.setStatus(2);
+                        activeLiveList.add( live);
+                    } else if (now.isBefore(live.getStartTime().minusSeconds(2L))) {
+                        live.setStatus(1);
+                    } else if (now.isAfter(live.getFinishTime().minusSeconds(2L))) {
+                        live.setStatus(3);
+                    }
                 }
             } else {
-                if (now.isAfter(live.getStartTime()) && now.isBefore(live.getFinishTime())) {
-                    live.setStatus(2);
-                    activeLiveList.add( live);
-                } else if (now.isBefore(live.getStartTime())) {
-                    live.setStatus(1);
-                } else if (now.isAfter(live.getFinishTime())) {
-                    live.setStatus(3);
+                // 直播回放只需要检测结束时间就好了
+                LiveReplayParam liveReplayParam = JSON.parseObject(live.getLiveConfig(), LiveReplayParam.class);
+                if (liveReplayParam.getIsPlaybackOpen()) {
+                    if (liveReplayParam.getFinishTime() != null) {
+                        if (now.isAfter(live.getFinishTime().minusSeconds(2L))) {
+                            live.setStatus(3);
+                        }
+                    }
                 }
             }
+
         });
         String key = "live:auto_task:";
         if(!activeLiveList.isEmpty()){
@@ -95,6 +111,7 @@ public class Task {
                         liveAutoTask.setCreateTime(null);
                         liveAutoTask.setUpdateTime(null);
                         redisCache.redisTemplate.opsForZSet().add(key + live.getLiveId(), JSON.toJSONString(liveAutoTask),liveAutoTask.getAbsValue().getTime());
+                        redisCache.redisTemplate.expire(key+live.getLiveId(), 30, java.util.concurrent.TimeUnit.MINUTES);
                     });
                 }
             });
@@ -107,15 +124,38 @@ public class Task {
     @Scheduled(cron = "0/1 * * * * ?")
     public void liveLotteryTask() {
         long currentTime = Instant.now().toEpochMilli(); // 当前时间戳(毫秒)
-        String key = "live:lottery_task";
+        String lotteryKey = "live:lottery_task:*";
+        Set<String> allLiveKeys = redisCache.redisTemplate.keys(lotteryKey);
+        if (allLiveKeys != null && !allLiveKeys.isEmpty()) {
+            for (String liveKey : allLiveKeys) {
+                Set<String> range = redisCache.redisTemplate.opsForZSet().rangeByScore(liveKey, 0, currentTime);
+                if (range == null || range.isEmpty()) {
+                    continue;
+                }
+                processLotteryTask(range);
+                redisCache.redisTemplate.opsForZSet()
+                        .removeRangeByScore(liveKey, 0, currentTime);
+            }
+        }
 
-        Set<String> range = redisCache.redisTemplate.opsForZSet().rangeByScore(key, 0, currentTime);
-        if (range == null || range.isEmpty()) {
+        String redKey = "live:red_task:*";
+        allLiveKeys = redisCache.redisTemplate.keys(redKey);
+        if (allLiveKeys == null || allLiveKeys.isEmpty()) {
             return;
         }
-        redisCache.redisTemplate.opsForZSet()
-                .removeRangeByScore(key, 0, currentTime);
-        processLotteryTask(range);
+        for (String liveKey : allLiveKeys) {
+            Set<String> range = redisCache.redisTemplate.opsForZSet().rangeByScore(liveKey, 0, currentTime);
+            if (range == null || range.isEmpty()) {
+                continue;
+            }
+            updateRedStatus(range);
+            redisCache.redisTemplate.opsForZSet()
+                    .removeRangeByScore(liveKey, 0, currentTime);
+        }
+    }
+
+    private void updateRedStatus(Set<String> range) {
+        liveRedConfService.finishRedStatusBySetIds(range);
     }
 
     private void processLotteryTask(Set<String> range) {
@@ -163,6 +203,7 @@ public class Task {
                     liveWatchUsers.remove(randomIndex);
                     LotteryVo lotteryVo = new LotteryVo();
                     lotteryVo.setUserId(winningUser.getUserId());
+                    lotteryVo.setUserName(winningUser.getNickName());
                     lotteryVo.setPrizeLevel(liveLotteryProductListVo.getPrizeLevel());
                     lotteryVo.setProductName(liveLotteryProductListVo.getProductName());
                     lotteryVos.add(lotteryVo);
@@ -172,8 +213,11 @@ public class Task {
             sendMsgVo.setLiveId(liveLottery.getLiveId());
             sendMsgVo.setCmd("LotteryDetail");
             sendMsgVo.setData(JSON.toJSONString(lotteryVos));
-            webSocketServer.broadcastMessage(liveLottery.getLotteryId(), JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+            webSocketServer.broadcastMessage(liveLottery.getLiveId(), JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
         }
+
+        List<Long> collect = liveLotteries.stream().map(LiveLotteryConfVo::getLotteryId).collect(Collectors.toList());
+        liveLotteryConfService.finishStatusByLotteryIds(collect);
     }
 
     @Scheduled(cron = "0/1 * * * * ?")
@@ -203,7 +247,7 @@ public class Task {
             LiveAutoTask task = JSON.parseObject(liveAutoTask, LiveAutoTask.class);
             webSocketServer.handleAutoTask(task);
             task.setFinishStatus(1L);
-            liveAutoTaskService.updateLiveAutoTask(task);
+            liveAutoTaskService.finishLiveAutoTask(task);
         }
     }
 

+ 4 - 0
fs-live-app/src/main/java/com/fs/app/websocket/service/WebSocketServer.java

@@ -64,6 +64,8 @@ public class WebSocketServer {
         long liveId = (long) userProperties.get("liveId");
         long userId = (long) userProperties.get("userId");
         long userType = (long) userProperties.get("userType");
+        long companyId = (long) userProperties.get("companyId");
+        long companyUserId = (long) userProperties.get("companyUserId");
 
         if (liveService.getById(liveId) == null) {
             throw new BaseException("未找到直播间");
@@ -125,6 +127,8 @@ public class WebSocketServer {
                 LiveUserFirstEntry liveUserFirstEntry = new LiveUserFirstEntry();
                 liveUserFirstEntry.setUserId(userId);
                 liveUserFirstEntry.setLiveId(liveId);
+                liveUserFirstEntry.setCompanyId(companyId);
+                liveUserFirstEntry.setCompanyUserId(companyUserId);
                 liveUserFirstEntry.setEntryDate(date);
                 liveUserFirstEntry.setFirstEntryTime(date);
                 liveUserFirstEntry.setUpdateTime( date);

+ 2 - 2
fs-service/src/main/java/com/fs/his/mapper/FsStoreProductMapper.java

@@ -39,7 +39,7 @@ public interface FsStoreProductMapper {
 
     @Select({"<script> " +
             "select p.*,pc.cate_name,st.store_name  from fs_store_product p left join fs_store_product_category pc on p.cate_id=pc.cate_id LEFT JOIN fs_store st ON st.store_id=p.store_id  " +
-            "where 1=1 " +
+            "where 1=1 and is_show = 1" +
             "<if test = 'maps.productName != null and  maps.productName !=\"\"    '> " +
             "and p.product_name like CONCAT('%',#{maps.productName},'%') " +
             "</if>" +
@@ -264,7 +264,7 @@ public interface FsStoreProductMapper {
 
     @Select({"<script> " +
             "select p.*,pc.cate_name,st.store_name  from fs_store_product p left join fs_store_product_category pc on p.cate_id=pc.cate_id LEFT JOIN fs_store st ON st.store_id=p.store_id  " +
-            "where 1=1 " +
+            "where 1=1 and p.is_show = 1" +
             "<if test = 'maps.productName != null and  maps.productName !=\"\"    '> " +
             "and p.product_name like CONCAT('%',#{maps.productName},'%') " +
             "</if>" +

+ 5 - 2
fs-service/src/main/java/com/fs/live/domain/Live.java

@@ -53,7 +53,7 @@ public class    Live extends BaseEntity {
     private Integer showType;
 
     /** 1待支付 2直播中 3已结束 */
-    @Excel(name = "1未开播 2直播中 3已结束")
+    @Excel(name = "1未开播 2直播中 3已结束 4直播回放中")
     private Integer status;
 
     /** 直播ID */
@@ -61,7 +61,7 @@ public class    Live extends BaseEntity {
     private Long anchorId;
 
     /** 直播类型 1直播,2录播 */
-    @Excel(name = "直播类型 1直播,2录播")
+    @Excel(name = "直播类型 1直播,2录播,3直播回放")
     private Integer liveType;
 
     /** 开始时间 */
@@ -105,6 +105,9 @@ public class    Live extends BaseEntity {
     @TableField(exist = false)
     private Long duration;
 
+    @TableField(exist = false)
+    private String liveCodeUrl;
+
     /** 直播配置 */
     private String configJson;
 

+ 39 - 0
fs-service/src/main/java/com/fs/live/domain/LiveCompanyCode.java

@@ -0,0 +1,39 @@
+package com.fs.live.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 直播间销售小程序二维码对象 live_company_code
+ *
+ * @author fs
+ * @date 2025-09-10
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class LiveCompanyCode extends BaseEntity{
+
+    /** 主键 */
+    private Long id;
+
+    /** 直播间唯一标识 */
+    @Excel(name = "直播间唯一标识")
+    private Long liveId;
+
+    /** 企业唯一标识 */
+    @Excel(name = "企业唯一标识")
+    private Long companyId;
+
+    /** 企业用户唯一标识 */
+    @Excel(name = "企业用户唯一标识")
+    private Long companyUserId;
+
+    /** 直播间代码URL */
+    @Excel(name = "直播间代码URL")
+    private String liveCodeUrl;
+
+
+}

+ 4 - 0
fs-service/src/main/java/com/fs/live/domain/LiveGoods.java

@@ -52,6 +52,10 @@ public class LiveGoods extends BaseEntity{
     @Excel(name = "库存表")
     private Long stock;
 
+    /** 库存表 */
+    @Excel(name = "销量")
+    private Integer sales;
+
     /** 排序号 */
     @Excel(name = "排序号")
     private Long sort;

+ 8 - 0
fs-service/src/main/java/com/fs/live/domain/LiveUserFirstEntry.java

@@ -29,6 +29,14 @@ public class LiveUserFirstEntry extends BaseEntity{
     @Excel(name = "直播间ID")
     private Long liveId;
 
+    /** 公司id */
+    @Excel(name = "公司id")
+    private Long companyId;
+
+    /** 公司用户id */
+    @Excel(name = "公司用户id")
+    private Long companyUserId;
+
     /** 进入日期 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "进入日期", width = 30, dateFormat = "yyyy-MM-dd")

+ 5 - 0
fs-service/src/main/java/com/fs/live/domain/LiveWatchUser.java

@@ -1,5 +1,6 @@
 package com.fs.live.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntityTow;
 import lombok.Data;
@@ -32,4 +33,8 @@ public class LiveWatchUser extends BaseEntityTow {
     @Excel(name = "在线状态;0在线1离线")
     private Integer online;
 
+    /** 用户名字 */
+    @TableField(exist = false)
+    private String nickName;
+
 }

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

@@ -7,6 +7,8 @@ import com.fs.live.domain.LiveAutoTask;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.SelectProvider;
+import org.apache.ibatis.annotations.Update;
+
 import java.util.Map;
 
 /**
@@ -74,4 +76,7 @@ public interface LiveAutoTaskMapper extends BaseMapper<LiveAutoTask>{
     List<LiveAutoTask> selectNoActivedByLiveId(@Param("liveId") Long existLiveId,@Param("now") Date now);
 
     List<LiveAutoTask> selectLiveAutoTaskByLiveIds(@Param("liveIdLists") List<Long> liveIdLists, @Param("now") Date now);
+
+    @Update("update live_auto_task set finish_status = 1 where id = #{id}")
+    void finishLiveAutoTask(LiveAutoTask task);
 }

+ 66 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveCompanyCodeMapper.java

@@ -0,0 +1,66 @@
+package com.fs.live.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.live.domain.LiveCompanyCode;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+/**
+ * 直播间销售小程序二维码Mapper接口
+ *
+ * @author fs
+ * @date 2025-09-10
+ */
+public interface LiveCompanyCodeMapper extends BaseMapper<LiveCompanyCode>{
+    /**
+     * 查询直播间销售小程序二维码
+     *
+     * @param id 直播间销售小程序二维码主键
+     * @return 直播间销售小程序二维码
+     */
+    LiveCompanyCode selectLiveCompanyCodeById(Long id);
+
+    /**
+     * 查询直播间销售小程序二维码列表
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 直播间销售小程序二维码集合
+     */
+    List<LiveCompanyCode> selectLiveCompanyCodeList(LiveCompanyCode liveCompanyCode);
+
+    /**
+     * 新增直播间销售小程序二维码
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 结果
+     */
+    int insertLiveCompanyCode(LiveCompanyCode liveCompanyCode);
+
+    /**
+     * 修改直播间销售小程序二维码
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 结果
+     */
+    int updateLiveCompanyCode(LiveCompanyCode liveCompanyCode);
+
+    /**
+     * 删除直播间销售小程序二维码
+     *
+     * @param id 直播间销售小程序二维码主键
+     * @return 结果
+     */
+    int deleteLiveCompanyCodeById(Long id);
+
+    /**
+     * 批量删除直播间销售小程序二维码
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteLiveCompanyCodeByIds(Long[] ids);
+
+    @Select("select * from live_company_code where live_id=#{liveId} and company_id=#{companyId} and company_user_id=#{companyUserId}")
+    LiveCompanyCode selectByLiveIdAndUser(@Param("liveId") Long liveId,@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
+}

+ 4 - 4
fs-service/src/main/java/com/fs/live/mapper/LiveGoodsMapper.java

@@ -156,9 +156,9 @@ public interface LiveGoodsMapper extends BaseMapper<LiveGoods>{
     List<LiveGoods> selectLiveGoodsByLiveId(@Param("liveId") Long liveId);
 
     @Update({"<script>" +
-            "update live_goods set is_show " +
-            "CASE WHEN goods_id=#{goodsId} THEN 1" +
-            "ELSE 0 where live_id = #{liveId}" +
+            "update live_goods set is_show =" +
+            "CASE WHEN goods_id=#{goodsId} THEN 1 " +
+            "ELSE 0 END where live_id = #{liveId}" +
             "</script>"})
-    void updateLiveIsShow(Long goodsId, Long liveId);
+    void updateLiveIsShow(@Param("goodsId")Long goodsId,@Param("liveId") Long liveId);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveLotteryConfMapper.java

@@ -96,4 +96,6 @@ public interface LiveLotteryConfMapper extends BaseMapper<LiveLotteryConf>{
     List<LiveLotteryConfVo> selectByLotteryIds(@Param("ids") Set<String> ids);
 
     LiveLotteryConfVo selectLiveLotteryConfVoByLotteryId(@Param("lotteryId") Long lotteryId);
+
+    void finishStatusByLotteryIds(@Param("ids")  List<Long> ids);
 }

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

@@ -1,6 +1,8 @@
 package com.fs.live.mapper;
 
 import java.util.List;
+import java.util.Set;
+
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.live.domain.LiveRedConf;
 import org.apache.ibatis.annotations.*;
@@ -90,4 +92,6 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
     @Select("SELECT * FROM live_red_conf WHERE red_status = 1 AND live_id = #{liveId} " +
             "AND red_id NOT IN (SELECT red_id FROM live_user_red_record WHERE user_id = #{userId})")
     List<LiveRedConf> selectActivedRed(@Param("liveId") Long liveId, @Param("userId") String userId);
+
+    void finishRedStatusBySetIds(@Param("ids") Set<String> ids);
 }

+ 2 - 2
fs-service/src/main/java/com/fs/live/mapper/LiveWatchUserMapper.java

@@ -95,8 +95,8 @@ public interface LiveWatchUserMapper extends BaseMapper<LiveWatchUser>{
 
     List<LiveWatchUser> checkOnlineNoRewardUser(@Param("liveId") Long liveId,@Param("now") Date now);
 
-    @Select("select * from live_watch_user where live_id=#{liveId} and online = 1 and " +
+    @Select("select a.*,fu.nick_name from (select lws.* from live_watch_user lws where live_id=#{liveId} and online = 0 and " +
             "user_id in (select user_id from live_lottery_registration where live_id = #{liveId} and lottery_id=#{lotteryId} and registration_id >= " +
-            "(SELECT FLOOR(RAND() * (SELECT MAX(registration_id) FROM live_lottery_registration)))) limit #{totalLots}")
+            "(SELECT FLOOR(RAND() * (SELECT MAX(registration_id) FROM live_lottery_registration)))) limit #{totalLots} ) a left join fs_user fu on fu.user_id = a.user_id")
     List<LiveWatchUser> selectLiveWatchAndRegisterUser(@Param("liveId") Long liveId,@Param("lotteryId") Long lotteryId,@Param("totalLots") Integer totalLots);
 }

+ 16 - 0
fs-service/src/main/java/com/fs/live/param/LiveReplayParam.java

@@ -0,0 +1,16 @@
+package com.fs.live.param;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class LiveReplayParam {
+    private Boolean isPlaybackOpen;
+    private String playbackMode;
+    private String validityType;
+    private Integer validDays;
+    private String isSpeedAllowed;
+    private LocalDateTime startTime;
+    private LocalDateTime finishTime;
+}

+ 0 - 4
fs-service/src/main/java/com/fs/live/param/LotteryPO.java

@@ -15,10 +15,6 @@ public class LotteryPO {
      * */
     private Long lotteryId;
 
-    /**
-     * 红包金额
-     * */
-    private Long integral;
 
     /**
      * 用户Id

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

@@ -75,4 +75,6 @@ public interface ILiveAutoTaskService extends IService<LiveAutoTask>{
     List<LiveAutoTask> selectLiveAutoTaskByLiveIds(List<Long> liveIdLists);
 
     void recalcLiveAutoTask(Long liveId);
+
+    void finishLiveAutoTask(LiveAutoTask task);
 }

+ 63 - 0
fs-service/src/main/java/com/fs/live/service/ILiveCompanyCodeService.java

@@ -0,0 +1,63 @@
+package com.fs.live.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.live.domain.LiveCompanyCode;
+
+/**
+ * 直播间销售小程序二维码Service接口
+ *
+ * @author fs
+ * @date 2025-09-10
+ */
+public interface ILiveCompanyCodeService extends IService<LiveCompanyCode>{
+    /**
+     * 查询直播间销售小程序二维码
+     *
+     * @param id 直播间销售小程序二维码主键
+     * @return 直播间销售小程序二维码
+     */
+    LiveCompanyCode selectLiveCompanyCodeById(Long id);
+
+    /**
+     * 查询直播间销售小程序二维码列表
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 直播间销售小程序二维码集合
+     */
+    List<LiveCompanyCode> selectLiveCompanyCodeList(LiveCompanyCode liveCompanyCode);
+
+    /**
+     * 新增直播间销售小程序二维码
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 结果
+     */
+    int insertLiveCompanyCode(LiveCompanyCode liveCompanyCode);
+
+    /**
+     * 修改直播间销售小程序二维码
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 结果
+     */
+    int updateLiveCompanyCode(LiveCompanyCode liveCompanyCode);
+
+    /**
+     * 批量删除直播间销售小程序二维码
+     *
+     * @param ids 需要删除的直播间销售小程序二维码主键集合
+     * @return 结果
+     */
+    int deleteLiveCompanyCodeByIds(Long[] ids);
+
+    /**
+     * 删除直播间销售小程序二维码信息
+     *
+     * @param id 直播间销售小程序二维码主键
+     * @return 结果
+     */
+    int deleteLiveCompanyCodeById(Long id);
+
+    LiveCompanyCode selectByLiveIdAndUser(Long liveId, Long companyId, Long userId);
+}

+ 3 - 1
fs-service/src/main/java/com/fs/live/service/ILiveLotteryConfService.java

@@ -48,7 +48,7 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
-    int updateLiveLotteryConf(LiveLotteryConf liveLotteryConf);
+    R updateLiveLotteryConf(LiveLotteryConf liveLotteryConf);
 
     /**
      * 批量删除直播抽奖配置
@@ -93,4 +93,6 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
     List<LiveLotteryConfVo> selectVoListByLotteryIds(Set<String> range);
 
     R detail(LotteryPO lottery);
+
+    void finishStatusByLotteryIds(List<Long> ids);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/live/service/ILiveRedConfService.java

@@ -1,6 +1,8 @@
 package com.fs.live.service;
 
 import java.util.List;
+import java.util.Set;
+
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.common.core.domain.R;
 import com.fs.live.domain.LiveRedConf;
@@ -78,4 +80,7 @@ public interface ILiveRedConfService extends IService<LiveRedConf>{
     List<LiveRedConf> selectByLiveId(Long existLiveId);
 
     List<LiveRedConf> selectActivedRed(Long liveId, String userId);
+
+    // 结算掉红包
+    void finishRedStatusBySetIds(Set<String> range);
 }

+ 10 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java

@@ -106,6 +106,7 @@ public class LiveAutoTaskServiceImpl extends ServiceImpl<LiveAutoTaskMapper, Liv
             liveAutoTask.setUpdateTime(null);
             liveAutoTask.setCreateTime(null);
             redisCache.redisTemplate.opsForZSet().add("live:auto_task:" + live.getLiveId(), JSON.toJSONString(liveAutoTask),liveAutoTask.getAbsValue().getTime());
+            redisCache.redisTemplate.expire("live:auto_task:" + live.getLiveId(), 30, java.util.concurrent.TimeUnit.MINUTES);
         }
 
 
@@ -145,6 +146,7 @@ public class LiveAutoTaskServiceImpl extends ServiceImpl<LiveAutoTaskMapper, Liv
             liveAutoTask.setUpdateTime(null);
             liveAutoTask.setCreateTime(null);
             redisCache.redisTemplate.opsForZSet().add("live:auto_task:" + live.getLiveId(), JSON.toJSONString(liveAutoTask),liveAutoTask.getAbsValue().getTime());
+            redisCache.redisTemplate.expire("live:auto_task:" + live.getLiveId(), 30, java.util.concurrent.TimeUnit.MINUTES);
         }
         return R.ok();
     }
@@ -173,6 +175,9 @@ public class LiveAutoTaskServiceImpl extends ServiceImpl<LiveAutoTaskMapper, Liv
     {
         LiveAutoTask existTask = baseMapper.selectLiveAutoTaskById(liveAutoTask.getId());
         redisCache.redisTemplate.opsForZSet().removeRangeByScore("live:auto_task:" + existTask.getLiveId(), existTask.getAbsValue().getTime(), existTask.getAbsValue().getTime());
+        LiveGoodsVo liveGoodsVo = goodsService.selectLiveGoodsVoByGoodsId(Long.valueOf(liveAutoTask.getContent()));
+        if(liveGoodsVo == null) return -1;
+        liveAutoTask.setContent(JSON.toJSONString(liveGoodsVo));
 
         return baseMapper.updateLiveAutoTask(liveAutoTask);
     }
@@ -229,4 +234,9 @@ public class LiveAutoTaskServiceImpl extends ServiceImpl<LiveAutoTaskMapper, Liv
             baseMapper.updateLiveAutoTask(liveAutoTask);
         }
     }
+
+    @Override
+    public void finishLiveAutoTask(LiveAutoTask task) {
+        baseMapper.finishLiveAutoTask(task);
+    }
 }

+ 99 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveCompanyCodeServiceImpl.java

@@ -0,0 +1,99 @@
+package com.fs.live.service.impl;
+
+import java.util.List;
+import com.fs.common.utils.DateUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.fs.live.mapper.LiveCompanyCodeMapper;
+import com.fs.live.domain.LiveCompanyCode;
+import com.fs.live.service.ILiveCompanyCodeService;
+
+/**
+ * 直播间销售小程序二维码Service业务层处理
+ *
+ * @author fs
+ * @date 2025-09-10
+ */
+@Service
+public class LiveCompanyCodeServiceImpl extends ServiceImpl<LiveCompanyCodeMapper, LiveCompanyCode> implements ILiveCompanyCodeService {
+
+    /**
+     * 查询直播间销售小程序二维码
+     *
+     * @param id 直播间销售小程序二维码主键
+     * @return 直播间销售小程序二维码
+     */
+    @Override
+    public LiveCompanyCode selectLiveCompanyCodeById(Long id)
+    {
+        return baseMapper.selectLiveCompanyCodeById(id);
+    }
+
+    /**
+     * 查询直播间销售小程序二维码列表
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 直播间销售小程序二维码
+     */
+    @Override
+    public List<LiveCompanyCode> selectLiveCompanyCodeList(LiveCompanyCode liveCompanyCode)
+    {
+        return baseMapper.selectLiveCompanyCodeList(liveCompanyCode);
+    }
+
+    /**
+     * 新增直播间销售小程序二维码
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 结果
+     */
+    @Override
+    public int insertLiveCompanyCode(LiveCompanyCode liveCompanyCode)
+    {
+        liveCompanyCode.setCreateTime(DateUtils.getNowDate());
+        return baseMapper.insertLiveCompanyCode(liveCompanyCode);
+    }
+
+    /**
+     * 修改直播间销售小程序二维码
+     *
+     * @param liveCompanyCode 直播间销售小程序二维码
+     * @return 结果
+     */
+    @Override
+    public int updateLiveCompanyCode(LiveCompanyCode liveCompanyCode)
+    {
+        liveCompanyCode.setUpdateTime(DateUtils.getNowDate());
+        return baseMapper.updateLiveCompanyCode(liveCompanyCode);
+    }
+
+    /**
+     * 批量删除直播间销售小程序二维码
+     *
+     * @param ids 需要删除的直播间销售小程序二维码主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveCompanyCodeByIds(Long[] ids)
+    {
+        return baseMapper.deleteLiveCompanyCodeByIds(ids);
+    }
+
+    /**
+     * 删除直播间销售小程序二维码信息
+     *
+     * @param id 直播间销售小程序二维码主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveCompanyCodeById(Long id)
+    {
+        return baseMapper.deleteLiveCompanyCodeById(id);
+    }
+
+    @Override
+    public LiveCompanyCode selectByLiveIdAndUser(Long liveId, Long companyId, Long userId) {
+        return baseMapper.selectByLiveIdAndUser(liveId, companyId, userId);
+    }
+}

+ 3 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveGoodsServiceImpl.java

@@ -194,6 +194,8 @@ public class LiveGoodsServiceImpl extends ServiceImpl<LiveGoodsMapper, LiveGoods
                     liveGoods.setStoreId(product.getStoreId());
                     liveGoods.setProductId(product.getProductId());
                     liveGoods.setStatus(1);
+                    liveGoods.setIsShow(false);
+                    liveGoods.setSales(product.getSales());
                     liveGoods.setStock(Long.valueOf(product.getStock()));
                     liveGoods.setSort(product.getSort());
                     liveGoods.setCreateTime(DateUtils.getNowDate());
@@ -227,6 +229,7 @@ public class LiveGoodsServiceImpl extends ServiceImpl<LiveGoodsMapper, LiveGoods
                     liveGoods.setProductId(product.getProductId());
                     liveGoods.setStatus(1);
                     liveGoods.setStock(Long.valueOf(product.getStock()));
+                    liveGoods.setSales(product.getSales());
                     liveGoods.setSort(product.getSort());
                     liveGoods.setCreateTime(DateUtils.getNowDate());
                     liveGoods.setCreateBy(String.valueOf(user.getUserId()));

+ 13 - 4
fs-service/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java

@@ -87,21 +87,23 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
      * @return 结果
      */
     @Override
-    public int updateLiveLotteryConf(LiveLotteryConf liveLotteryConf)
+    public R updateLiveLotteryConf(LiveLotteryConf liveLotteryConf)
     {
-        String cacheKey = "live:lottery_task";
+        String cacheKey = "live:lottery_task:" + liveLotteryConf.getLiveId();
+        liveLotteryConf.setUpdateTime(DateUtils.getNowDate());
         if ("1".equals(liveLotteryConf.getLotteryStatus())) {
             List<LiveLotteryProduct> prizes = productMapper.selectLiveLotteryProductConfByLotteryId(liveLotteryConf.getLotteryId());
             if (prizes == null || prizes.isEmpty()) {
-                throw new RuntimeException("请先添加奖品");
+                return R.error("请先添加奖品");
             }
             LocalDateTime localDateTime = LocalDateTime.now().plusMinutes(liveLotteryConf.getDuration());
             double score = localDateTime.atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli();
             redisCache.redisTemplate.opsForZSet().add(cacheKey, String.valueOf(liveLotteryConf.getLotteryId()), score);
+            redisCache.redisTemplate.expire(cacheKey, 30, java.util.concurrent.TimeUnit.MINUTES);
         } else {
             redisCache.deleteObject(cacheKey);
         }
-        return baseMapper.updateLiveLotteryConf(liveLotteryConf);
+        return R.ok().put("data",baseMapper.updateLiveLotteryConf(liveLotteryConf));
 
     }
 
@@ -256,4 +258,11 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
         liveLotteryConf.setProducts(prizes);
         return R.ok().put("data", liveLotteryConf);
     }
+
+    @Override
+    public void finishStatusByLotteryIds(List<Long> ids) {
+        baseMapper.finishStatusByLotteryIds(ids);
+    }
+
+
 }

+ 5 - 4
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -1087,12 +1087,12 @@ public class LiveOrderServiceImpl extends ServiceImpl<LiveOrderMapper, LiveOrder
         if(liveOrder.getTotalNum() == null) return R.error("商品数量不能为空");
 
         Live live = liveMapper.selectLiveByLiveId(liveOrder.getLiveId());
-        if(live == null) return R.error("直播不存在");
+        if(live == null) return R.error("当前直播不存在");
         FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductByProductId(liveOrder.getProductId());
         LiveGoods goods = liveGoodsMapper.selectLiveGoodsByProductId(liveOrder.getLiveId(), liveOrder.getProductId());
-        if(fsStoreProduct == null) return R.error("商品不存在");
-        if(fsStoreProduct.getIsShow() == 0 || goods.getStatus() == 0) return R.error("商品已下架");
-        if(fsStoreProduct.getStock() < Integer.parseInt(liveOrder.getTotalNum()) || goods.getStock() < Integer.parseInt(liveOrder.getTotalNum())) return R.error("库存不足");
+        if(fsStoreProduct == null) return R.error("店铺已下架商品,购买失败");
+        if(fsStoreProduct.getIsShow() == 0 || goods.getStatus() == 0) return R.error("商品已下架,购买失败");
+        if(fsStoreProduct.getStock() < Integer.parseInt(liveOrder.getTotalNum()) || goods.getStock() < Integer.parseInt(liveOrder.getTotalNum())) return R.error("抱歉,这款商品已被抢光,暂时无库存~");
 
         // 更改店铺库存
         fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
@@ -1114,6 +1114,7 @@ public class LiveOrderServiceImpl extends ServiceImpl<LiveOrderMapper, LiveOrder
 //        liveOrder.setOrderCode(String.valueOf(UUID.randomUUID()));
         liveOrder.setCreateTime(new Date());
         liveOrder.setUpdateTime(new Date());
+        liveOrder.setProductId(fsStoreProduct.getProductId());
         liveOrder.setStatus(FsStoreOrderStatusEnum.STATUS_1.getValue());
         liveOrder.setPayType("1");
         liveOrder.setTotalPrice(fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum())));

+ 15 - 5
fs-service/src/main/java/com/fs/live/service/impl/LiveRedConfServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fs.live.service.impl;
 
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
@@ -90,15 +91,19 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
     @Override
     public int updateLiveRedConf(LiveRedConf liveRedConf)
     {
+        String cacheKey = "live:red_task:" + liveRedConf.getLiveId();
+        liveRedConf.setUpdateTime(DateUtils.getNowDate());
         // 开始
         if (liveRedConf.getRedStatus() == 1) {
             setRemaining(liveRedConf.getRedId(), liveRedConf.getTotalLots());
-        } else if (liveRedConf.getRedStatus() == 2) {
-            // 结算
-            redisCache.deleteObject(REDPACKET_REMAININGLOTS_KEY + liveRedConf.getRedId());
-        } else if (liveRedConf.getRedStatus() == 3) {
-            // 暂停
+            LocalDateTime localDateTime = LocalDateTime.now().plusMinutes(liveRedConf.getDuration());
+            double score = localDateTime.atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli();
+            redisCache.redisTemplate.opsForZSet().add(cacheKey, String.valueOf(liveRedConf.getRedId()), score);
+            redisCache.redisTemplate.expire(cacheKey, 30, java.util.concurrent.TimeUnit.MINUTES);
+        } else {
+            // 其他
             redisCache.deleteObject(REDPACKET_REMAININGLOTS_KEY + liveRedConf.getRedId());
+            redisCache.deleteObject(cacheKey);
         }
         return baseMapper.updateLiveRedConf(liveRedConf);
     }
@@ -250,6 +255,11 @@ public class LiveRedConfServiceImpl extends ServiceImpl<LiveRedConfMapper, LiveR
         return baseMapper.selectActivedRed(liveId, userId);
     }
 
+    @Override
+    public void finishRedStatusBySetIds(Set<String> range) {
+        baseMapper.finishRedStatusBySetIds(range);
+    }
+
     // 初始化剩余数量
     public void initRemainingLots(Long redId, Integer totalLots) {
         String key = REDPACKET_REMAININGLOTS_KEY + redId;

+ 20 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -14,6 +14,7 @@ import com.fs.course.domain.FsUserTalent;
 import com.fs.course.service.IFsUserTalentService;
 import com.fs.live.domain.*;
 import com.fs.live.mapper.*;
+import com.fs.live.param.LiveReplayParam;
 import com.fs.live.service.*;
 import com.fs.live.utils.ProcessManager;
 import com.fs.live.vo.LiveListVo;
@@ -213,6 +214,24 @@ public class LiveServiceImpl extends ServiceImpl<LiveMapper, Live> implements IL
             liveVideo.setDuration(live.getDuration());
             liveVideoService.updateById(liveVideo);
         }
+        if (StringUtils.isNotEmpty(live.getLiveConfig())) {
+            LiveReplayParam liveReplayParam = JSON.parseObject(live.getLiveConfig(), LiveReplayParam.class);
+            if (liveReplayParam.getIsPlaybackOpen()) {
+                liveReplayParam.setStartTime(live.getFinishTime());
+                if ("permanent".equals(liveReplayParam.getValidityType())) {
+                    liveReplayParam.setFinishTime(null);
+                } else if ("days".equals(liveReplayParam.getValidityType())) {
+                    liveReplayParam.setFinishTime(live.getFinishTime().plusDays(liveReplayParam.getValidDays()));
+                }
+                live.setLiveType(3);
+                live.setStatus(4);
+            } else {
+                live.setLiveType(1);
+                live.setStatus(3);
+            }
+            live.setLiveConfig(JSON.toJSONString(liveReplayParam));
+
+        }
         int result = liveMapper.updateLive(live);
         liveAutoTaskService.recalcLiveAutoTask(live.getLiveId());
         return result;
@@ -546,6 +565,7 @@ public class LiveServiceImpl extends ServiceImpl<LiveMapper, Live> implements IL
                 liveRedConfEntity.setLiveId(newLiveId);
                 liveRedConfEntity.setRedStatus(0L);
                 liveRedConfEntity.setCreateTime(now);
+                liveRedConfEntity.setTotalSend(0L);
                 liveRedConfService.insertLiveRedConf(liveRedConfEntity);
             }
         }

+ 1 - 1
fs-service/src/main/java/com/fs/live/service/impl/LiveVideoServiceImpl.java

@@ -114,7 +114,7 @@ public class LiveVideoServiceImpl extends ServiceImpl<LiveVideoMapper, LiveVideo
 
     @Override
     public List<LiveVideo> listByLiveId(Long liveId, Integer type) {
-        return list(new QueryWrapper<LiveVideo>().eq("live_id", liveId).eq("video_type", type));
+        return list(new QueryWrapper<LiveVideo>().eq("live_id", liveId).in("video_type", type,2));
     }
 
     /**

+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/LiveGoodsVo.java

@@ -15,6 +15,7 @@ public class LiveGoodsVo {
     private BigDecimal price;
     private Integer stock;
     private Integer status;
+    private Integer fsStatus;
     private Integer sales;
     private Long productId;
     private BigDecimal otPrice;

+ 81 - 0
fs-service/src/main/resources/mapper/live/LiveCompanyCodeMapper.xml

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.live.mapper.LiveCompanyCodeMapper">
+
+    <resultMap type="LiveCompanyCode" id="LiveCompanyCodeResult">
+        <result property="id"    column="id"    />
+        <result property="liveId"    column="live_id"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
+        <result property="liveCodeUrl"    column="live_code_url"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectLiveCompanyCodeVo">
+        select id, live_id, company_id, company_user_id, live_code_url, create_time, update_time from live_company_code
+    </sql>
+
+    <select id="selectLiveCompanyCodeList" parameterType="LiveCompanyCode" resultMap="LiveCompanyCodeResult">
+        <include refid="selectLiveCompanyCodeVo"/>
+        <where>
+            <if test="liveId != null "> and live_id = #{liveId}</if>
+            <if test="companyId != null "> and company_id = #{companyId}</if>
+            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+            <if test="liveCodeUrl != null  and liveCodeUrl != ''"> and live_code_url = #{liveCodeUrl}</if>
+        </where>
+    </select>
+
+    <select id="selectLiveCompanyCodeById" parameterType="Long" resultMap="LiveCompanyCodeResult">
+        <include refid="selectLiveCompanyCodeVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertLiveCompanyCode" parameterType="LiveCompanyCode">
+        insert into live_company_code
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="liveId != null">live_id,</if>
+            <if test="companyId != null">company_id,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="liveCodeUrl != null">live_code_url,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="liveId != null">#{liveId},</if>
+            <if test="companyId != null">#{companyId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="liveCodeUrl != null">#{liveCodeUrl},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateLiveCompanyCode" parameterType="LiveCompanyCode">
+        update live_company_code
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="liveId != null">live_id = #{liveId},</if>
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="liveCodeUrl != null">live_code_url = #{liveCodeUrl},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteLiveCompanyCodeById" parameterType="Long">
+        delete from live_company_code where id = #{id}
+    </delete>
+
+    <delete id="deleteLiveCompanyCodeByIds" parameterType="String">
+        delete from live_company_code where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 16 - 9
fs-service/src/main/resources/mapper/live/LiveGoodsMapper.xml

@@ -20,10 +20,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="stock"    column="stock"    />
         <result property="sort"    column="sort"    />
         <result property="isShow"    column="is_show"    />
+        <result property="sales"    column="sales"    />
     </resultMap>
 
     <sql id="selectLiveGoodsVo">
-        select goods_id, live_id, company_id, company_user_id, store_id, product_id, create_time, create_by, update_by, update_time, remark, status, stock, sort,case when is_show = 1 then true else false end as is_show from live_goods
+        select goods_id, live_id, company_id, company_user_id,sales, store_id, product_id, create_time, create_by, update_by, update_time, remark, status, stock, sort,case when is_show = 1 then true else false end as is_show from live_goods
     </sql>
 
     <select id="selectLiveGoodsList" parameterType="LiveGoods" resultMap="LiveGoodsResult">
@@ -38,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="stock != null "> and stock = #{stock}</if>
             <if test="sort != null "> and sort = #{sort}</if>
             <if test="isShow != null "> and is_show = #{isShow}</if>
+            <if test="sales != null "> and sales = #{sales}</if>
         </where>
     </select>
 
@@ -63,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="stock != null">stock,</if>
             <if test="sort != null">sort,</if>
             <if test="isShow != null">is_show,</if>
+            <if test="sales != null">sales,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -79,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="stock != null">#{stock},</if>
             <if test="sort != null">#{sort},</if>
             <if test="isShow != null">#{isShow},</if>
+            <if test="sales != null">#{sales},</if>
          </trim>
     </insert>
 
@@ -99,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="stock != null">stock = #{stock},</if>
             <if test="sort != null">sort = #{sort},</if>
             <if test="isShow != null">is_show = #{isShow},</if>
+            <if test="sales != null">sales = #{sales},</if>
         </trim>
         where goods_id = #{goodsId}
     </update>
@@ -121,7 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         INSERT INTO live_goods (
         live_id, company_id, company_user_id, store_id,
         product_id, create_time, create_by, update_by,
-        update_time, remark, status, stock, sort, is_show
+        update_time, remark, status, stock, sort, is_show,sales
         ) VALUES
         <foreach collection="liveGoodsList" item="item" separator=",">
             (
@@ -152,7 +157,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{item.status},
             #{item.stock},
             #{item.sort},
-            #{item.isShow}
+            #{item.isShow},
+            #{item.sales}
             )
         </foreach>
     </insert>
@@ -165,7 +171,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectProductListByLiveId" parameterType="LiveGoods" resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.img_url,sp.product_name,sp.price,sp.stock,sp.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id,case when lg.is_show = 1 then true else false end as is_show
+        select lg.goods_id,sp.img_url,sp.product_name,sp.price,sp.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id,case when lg.is_show = 1 then true else false end as is_show
         from live_goods lg
         left join fs_store_product sp
         ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
@@ -180,6 +186,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="stock != null "> and stock = #{stock}</if>
             <if test="sort != null "> and sort = #{sort}</if>
             <if test="isShow != null "> and is_show = #{isShow}</if>
+            <if test="sales != null "> and sales = #{sales}</if>
             <if test="keywords != null and keywords != ''">
                 and sp.product_name like concat('%',#{keywords},'%')
             </if>
@@ -188,7 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectProductListByLiveIdAll" parameterType="LiveGoods" resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.img_url,sp.product_name,sp.price,lg.stock,sp.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id, case when lg.is_show = 1 then true else false end as is_show
+        select lg.goods_id,sp.img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id, case when lg.is_show = 1 then true else false end as is_show,sp.is_show as fs_status
         from live_goods lg
         left join fs_store_product sp
         ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
@@ -209,7 +216,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveGoodsVoByGoodsId"  resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.img_url,sp.product_name,sp.price,lg.stock,sp.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id, case when lg.is_show = 1 then true else false end as is_show
+        select lg.goods_id,sp.img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id, case when lg.is_show = 1 then true else false end as is_show,sp.is_show as fs_status
         from live_goods lg
         left join fs_store_product sp
         ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
@@ -221,7 +228,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="showGoods"  resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.img_url,sp.product_name,sp.price,lg.stock,sp.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id, case when lg.is_show = 1 then true else false end as is_show
+        select lg.goods_id,sp.img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,sp.store_id, case when lg.is_show = 1 then true else false end as is_show,sp.is_show as fs_status
         from live_goods lg
         left join fs_store_product sp
         ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
@@ -248,7 +255,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectProductListByOrder" parameterType="com.fs.live.domain.LiveOrder" resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select sp.img_url,sp.product_name,sp.price,lg.stock,sp.sales,sp.product_id,sp.ot_price, sp.store_id
+        select sp.img_url,sp.product_name,sp.price,sp.stock,sp.sales,sp.product_id,sp.ot_price, sp.store_id,sp.is_show as fs_status
         from fs_store_product sp
         <where>
             sp.product_id = #{productId}
@@ -259,7 +266,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select
             g.*,
             if(uf.favorite_id is not null, true, false) isFavorite,
-            p.img_url, p.product_name, p.price, p.sales, p.ot_price
+            p.img_url, p.product_name, p.price, g.sales, p.ot_price,p.is_show as fs_status
         from live_goods g
         left join fs_store_product p on p.product_id = g.product_id and p.is_show = 1
         left join live_user_favorite uf on uf.product_id = g.goods_id and uf.user_id = #{params.userId}

+ 8 - 0
fs-service/src/main/resources/mapper/live/LiveLotteryConfMapper.xml

@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null "> and create_time >= #{createTime} and create_time &lt; date_add(#{createTime}, interval 1 day)</if>
             <if test="lotteryStatus != null "> and lottery_status = #{lotteryStatus}</if>
         </where>
+order by create_time desc
     </select>
 
     <select id="selectLiveLotteryConfByLotteryId" parameterType="Long" resultMap="LiveLotteryConfResult">
@@ -101,6 +102,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </select>
 
+    <update id="finishStatusByLotteryIds" >
+        update live_lottery_conf set lottery_status = 2 where lottery_id in
+        <foreach item="lotteryId" collection="ids" open="(" separator="," close=")">
+            #{lotteryId}
+        </foreach>
+    </update>
+
     <select id="selectLiveLotteryConfVoByLotteryId" resultType="com.fs.live.vo.LiveLotteryConfVo">
         select * from live_lottery_conf where lottery_id = #{lotteryId}
     </select>

+ 15 - 5
fs-service/src/main/resources/mapper/live/LiveMapper.xml

@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="configJson"    column="config_json"    />
         <result property="isAudit"    column="is_audit"    />
         <result property="idCardUrl"    column="id_card_url"    />
+        <result property="liveCodeUrl"    column="live_code_url"    />
     </resultMap>
 
     <sql id="selectLiveVo">
@@ -45,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url from live
         a
         left join live_video b on a.live_id = b.live_id
-        where 1=1 and is_del = 0 and is_show = 1 and status = 2
+        where 1=1 and is_del = 0 and is_show = 1 and status in (2,4)
 
         order by create_time desc
     </select>
@@ -53,12 +54,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLiveList" parameterType="Live" 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 from live
-        a
+               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>
+
+        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 company_id = #{companyId}</if>
-        <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+        <if test="companyId != null "> and a.company_id = #{companyId}</if>
+        <if test="companyUserId != null "> and a.company_user_id = #{companyUserId}</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>

+ 2 - 0
fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml

@@ -237,6 +237,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="payIntegral != null">pay_integral,</if>
             <if test="backIntegral != null">back_integral,</if>
             <if test="isEditMoney != null">is_edit_money,</if>
+            <if test="productId != null">product_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -305,6 +306,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="payIntegral != null">#{payIntegral},</if>
             <if test="backIntegral != null">#{backIntegral},</if>
             <if test="isEditMoney != null">#{isEditMoney},</if>
+            <if test="productId != null">#{productId},</if>
          </trim>
     </insert>
 

+ 6 - 0
fs-service/src/main/resources/mapper/live/LiveRedConfMapper.xml

@@ -109,4 +109,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where red_id = #{redId}
     </select>
 
+    <update id="finishRedStatusBySetIds">
+        update live_red_conf set red_status = 2  where red_id in
+        <foreach item="redId" collection="ids" open="(" separator="," close=")">
+            #{redId}
+        </foreach>
+    </update>
 </mapper>

+ 17 - 7
fs-service/src/main/resources/mapper/live/LiveUserFirstEntryMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveUserFirstEntryMapper">
-    
+
     <resultMap type="LiveUserFirstEntry" id="LiveUserFirstEntryResult">
         <result property="id"    column="id"    />
         <result property="userId"    column="user_id"    />
@@ -12,27 +12,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="firstEntryTime"    column="first_entry_time"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
     </resultMap>
 
     <sql id="selectLiveUserFirstEntryVo">
-        select id, user_id, live_id, entry_date, first_entry_time, create_time, update_time from live_user_first_entry
+        select id, user_id, live_id, entry_date, first_entry_time,company_id,company_user_id, create_time, update_time from live_user_first_entry
     </sql>
 
     <select id="selectLiveUserFirstEntryList" parameterType="LiveUserFirstEntry" resultMap="LiveUserFirstEntryResult">
         <include refid="selectLiveUserFirstEntryVo"/>
-        <where>  
+        <where>
             <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
             <if test="liveId != null  and liveId != ''"> and live_id = #{liveId}</if>
             <if test="entryDate != null "> and entry_date = #{entryDate}</if>
             <if test="firstEntryTime != null "> and first_entry_time = #{firstEntryTime}</if>
+            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+            <if test="companyId != null "> and company_id = #{companyId}</if>
         </where>
     </select>
-    
+
     <select id="selectLiveUserFirstEntryById" parameterType="Long" resultMap="LiveUserFirstEntryResult">
         <include refid="selectLiveUserFirstEntryVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertLiveUserFirstEntry" parameterType="LiveUserFirstEntry" useGeneratedKeys="true" keyProperty="id">
         insert into live_user_first_entry
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -42,6 +46,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="firstEntryTime != null">first_entry_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="companyId != null">company_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userId != null and userId != ''">#{userId},</if>
@@ -50,6 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="firstEntryTime != null">#{firstEntryTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="companyId != null">#{companyId},</if>
          </trim>
     </insert>
 
@@ -62,6 +70,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="firstEntryTime != null">first_entry_time = #{firstEntryTime},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="companyId != null">company_id = #{companyId},</if>
         </trim>
         where id = #{id}
     </update>
@@ -71,9 +81,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLiveUserFirstEntryByIds" parameterType="String">
-        delete from live_user_first_entry where id in 
+        delete from live_user_first_entry where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+</mapper>