Browse Source

聊天室开启自动定时任务 直播自动任务 弹幕脚本

yuhongqi 1 week ago
parent
commit
a751f37a4c

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

@@ -54,6 +54,17 @@ public class LiveAutoTaskController extends BaseController
         List<LiveAutoTask> list = liveAutoTaskService.selectLiveAutoTaskList(liveAutoTask);
         return getDataTable(list);
     }
+    /**
+     * 查询直播间自动化任务配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:task:list')")
+    @GetMapping("/listBarrage")
+    public TableDataInfo listBarrage(LiveAutoTask liveAutoTask)
+    {
+        startPage();
+        List<LiveAutoTask> list = liveAutoTaskService.selectLiveAutoTaskBarrageList(liveAutoTask);
+        return getDataTable(list);
+    }
 
     /**
      * 导出直播间自动化任务配置列表
@@ -133,6 +144,13 @@ public class LiveAutoTaskController extends BaseController
         return util.exportExcel(barrageList, "直播间弹幕脚本数据");
     }
 
+    @GetMapping("/importTemplate")
+    public AjaxResult importTemplate()
+    {
+        ExcelUtil<LiveAutoTaskImportParam> util = new ExcelUtil<>(LiveAutoTaskImportParam.class);
+        return util.importTemplateExcel("导入模板");
+    }
+
     @PreAuthorize("@ss.hasPermi('live:task:export')")
     @PostMapping("/importData")
     public AjaxResult importLineData(@RequestParam("liveId") String liveId, MultipartFile file) throws Exception

+ 8 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveAutoTaskController.java

@@ -18,6 +18,7 @@ import com.fs.live.domain.Live;
 import com.fs.live.domain.LiveAutoTask;
 import com.fs.live.mapper.LiveMapper;
 import com.fs.live.service.ILiveAutoTaskService;
+import com.fs.store.domain.FsQuestions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -149,6 +150,13 @@ public class LiveAutoTaskController extends BaseController
         return util.exportExcel(barrageList, "直播间弹幕脚本数据");
     }
 
+    @GetMapping("/importTemplate")
+    public AjaxResult importTemplate()
+    {
+        ExcelUtil<LiveAutoTaskImportParam> util = new ExcelUtil<>(LiveAutoTaskImportParam.class);
+        return util.importTemplateExcel("导入模板");
+    }
+
     @PreAuthorize("@ss.hasPermi('live:task:export')")
     @PostMapping("/importData")
     public AjaxResult importLineData(@RequestParam("liveId") String liveId,MultipartFile file) throws Exception

+ 11 - 0
fs-live-socket/src/main/java/com/fs/live/task/Task.java

@@ -145,6 +145,17 @@ public class Task {
         if(!list.isEmpty()){
             for (Live live : list) {
                 liveService.updateLive(live);
+                if (live.getStatus() == 2) {
+                    SendMsgVo sendMsgVo = new SendMsgVo();
+                    sendMsgVo.setMsg("开始直播");
+                    sendMsgVo.setCmd("live_start");
+                    webSocketServer.broadcastMessage(live.getLiveId(), JSONObject.toJSONString(R.ok().put("data",sendMsgVo)));
+                }else if (live.getStatus() == 3) {
+                    SendMsgVo sendMsgVo = new SendMsgVo();
+                    sendMsgVo.setMsg("结束直播");
+                    sendMsgVo.setCmd("live_end");
+                    webSocketServer.broadcastMessage(live.getLiveId(), JSONObject.toJSONString(R.ok().put("data",sendMsgVo)));
+                }
             }
         }
     }

+ 1 - 1
fs-service-system/src/main/java/com/fs/crm/param/LiveAutoTaskImportParam.java

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
 public class LiveAutoTaskImportParam implements Serializable {
 
     @JsonFormat(pattern = "HH:mm:ss")
-    @Excel(name = "时间", width = 20, dateFormat = "HH:mm:ss")
+    @Excel(name = "时间(格式为 00:00:00)", width = 20, dateFormat = "HH:mm:ss")
     private String registerDate;
 
     @Excel(name = "昵称")

+ 15 - 2
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -1428,10 +1428,13 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             return null;
         }
         FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
+        BigDecimal totalPrice = BigDecimal.ZERO;
         BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+        totalPrice = totalPrice.add(payPrice);
         BigDecimal payDelivery = BigDecimal.ZERO;
         if (param.getCityId() == null) {
             payDelivery = handleDeliveryMoney(param.getCityId(), fsStoreProduct, param.getTotalNum());
+            totalPrice = totalPrice.add(payDelivery);
         }
 
         if(param.getCouponUserId()!=null){
@@ -1446,7 +1449,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
         return LiveOrderComputeDTO.builder().payPrice(payPrice)
                 .payDelivery(payDelivery)
-                .totalPrice(payPrice.add(payDelivery))
+                .totalPrice(totalPrice)
                 .build();
     }
 
@@ -2232,6 +2235,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
             goods.setStock(goods.getStock()+Long.parseLong(liveOrder.getTotalNum()));
             liveGoodsMapper.updateLiveGoods(goods);
+            this.refundCoupon(order);
 
             return R.ok("操作成功");
         }else {
@@ -2239,7 +2243,16 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         }
     }
 
-
+    private void refundCoupon(LiveOrder order) {
+        if(order.getCouponUserId()!=null){
+            LiveCouponUser couponUser=liveCouponUserService.selectLiveCouponUserById(order.getCouponUserId());
+            if(couponUser!=null){
+                couponUser.setStatus(0);
+                couponUser.setUseTime(null);
+                liveCouponUserService.updateLiveCouponUser(couponUser);
+            }
+        }
+    }
 
 
     /**

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

@@ -234,7 +234,7 @@ public class LiveServiceImpl implements ILiveService
             dataValue.setValue(mapData.get(k));
             data.put(k, dataValue);
         });
-//        notifyTask.setData(JSON.toJSONString(data));
+        notifyTask.setData(JSON.toJSONString(data));
 //        return R.ok("success");
         fsMiniprogramSubNotifyTaskMapper.insert(notifyTask);