Browse Source

重算所有的自动化任务,

yuhongqi 1 tháng trước cách đây
mục cha
commit
74ec667959

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

@@ -480,6 +480,10 @@ public class WebSocketServer {
             }else if (task.getTaskType() == 2L) {
                 msg.setCmd("red");
                 LiveRedConf liveRedConf = JSON.parseObject(task.getContent(), LiveRedConf.class);
+                if(liveRedConf.getRedStatus() != 0){
+                    log.error("红包状态应该为:未发放");
+                    return;
+                }
                 liveRedConf.setRedStatus(1L);
                 liveRedConf.setUpdateTime( now);
                 msg.setData(JSON.toJSONString(liveRedConf));
@@ -487,6 +491,10 @@ public class WebSocketServer {
             }else if (task.getTaskType() == 4L) {
                 msg.setCmd("lottery");
                 LiveLotteryConf liveLotteryConf = JSON.parseObject(task.getContent(), LiveLotteryConf.class);
+                if(!"0".equals(liveLotteryConf.getLotteryStatus()) ){
+                    log.error("抽奖状态应该为:未发放");
+                    return;
+                }
                 liveLotteryConf.setLotteryStatus("1");
                 liveLotteryConf.setUpdateTime( now);
                 msg.setData(JSON.toJSONString(liveLotteryConf));

+ 1 - 1
fs-service-system/src/main/java/com/fs/live/mapper/LiveAutoTaskMapper.java

@@ -69,7 +69,7 @@ public interface LiveAutoTaskMapper {
     @Select("select * from live_auto_task where live_id= #{liveId}")
     List<LiveAutoTask> selectLiveAutoTaskByLiveId(@Param("liveId") Long liveId);
 
-    @Select("select * from live_auto_task where live_id= #{liveId} and task_type in (1,3)")
+    @Select("select * from live_auto_task where live_id= #{liveId}")
     List<LiveAutoTask> recalcLiveAutoTaskQuery(@Param("liveId") Long liveId);
 
     @Select("select * from live_auto_task where live_id= #{liveId} and status=1 and finish_status = 0 and abs_value>#{now} order by abs_value")

+ 10 - 1
fs-service-system/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -22,10 +22,12 @@ import com.fs.live.service.*;
 import com.fs.live.utils.ProcessManager;
 import com.fs.live.vo.*;
 import com.fs.store.domain.FsMiniprogramSubNotifyTask;
+import com.fs.store.domain.FsStoreProduct;
 import com.fs.store.domain.FsUser;
 import com.fs.store.dto.TemplateMessageSendRequestDTO;
 import com.fs.store.enums.MiniAppNotifyTaskStatusEnum;
 import com.fs.store.mapper.FsMiniprogramSubNotifyTaskMapper;
+import com.fs.store.mapper.FsStoreProductMapper;
 import com.fs.store.mapper.FsUserMapper;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
@@ -96,6 +98,8 @@ public class LiveServiceImpl implements ILiveService
     private LiveCouponIssueMapper liveCouponIssueMapper;
     @Autowired
     private FsUserMapper fsUserMapper;
+    @Autowired
+    private FsStoreProductMapper fsStoreProductMapper;
 
     @Autowired
     private RedisUtil redisUtil;
@@ -387,7 +391,9 @@ public class LiveServiceImpl implements ILiveService
 
         }
         int result = baseMapper.updateLive(live);
-        liveAutoTaskService.recalcLiveAutoTask(live);
+        if (live.getStatus() == 2) {
+            liveAutoTaskService.recalcLiveAutoTask(live);
+        }
         return result;
     }
 
@@ -810,6 +816,8 @@ public class LiveServiceImpl implements ILiveService
         // 直播间商品
         List<LiveGoodsVo> goodsList = liveGoodsService.selectProductListByLiveId(queryParam);
         if (!goodsList.isEmpty()) {
+            List<String> goodsProductIds = goodsList.stream().map(item -> String.valueOf(item.getProductId())).collect(Collectors.toList());
+            Map<Long, FsStoreProduct> collect = fsStoreProductMapper.selectFsStoreProductByProductIds(goodsProductIds).stream().collect(Collectors.toMap(FsStoreProduct::getProductId, item -> item));
             LiveGoods liveGoodsEntity = new LiveGoods();
             for (LiveGoodsVo liveGoods : goodsList) {
                 BeanUtils.copyBeanProp(liveGoodsEntity, liveGoods);
@@ -817,6 +825,7 @@ public class LiveServiceImpl implements ILiveService
                 liveGoodsEntity.setLiveId(newLiveId);
                 liveGoodsEntity.setCreateTime(now);
                 liveGoodsEntity.setIsShow(false);
+                liveGoodsEntity.setStock(collect.containsKey(liveGoods.getProductId()) ? collect.get(liveGoods.getProductId()).getStock() : 0);
                 liveGoodsEntity.setCompanyId(live.getCompanyId());
                 liveGoodsEntity.setCompanyUserId(live.getCompanyUserId());
                 liveGoodsService.insertLiveGoods(liveGoodsEntity);