Parcourir la source

提交修复bug

yuhongqi il y a 1 mois
Parent
commit
1f77f1f169

+ 2 - 0
fs-admin/src/main/java/com/fs/core/aspectj/LiveControllerAspect.java

@@ -26,6 +26,8 @@ public class LiveControllerAspect {
             "execution(* com.fs.live.controller.LiveController.handleShelfOrUn(..)) || " +
             "execution(* com.fs.live.controller.LiveController.edit(..)) || " +
             "execution(* com.fs.live.controller.LiveController.copyLive(..)) || " +
+            "execution(* com.fs.live.controller.LiveController.startLive(..)) || " +
+            "execution(* com.fs.live.controller.LiveController.updateLiveIsAudit(..)) || " +
             "execution(* com.fs.live.controller.LiveController.remove(..)) " ,
             returning = "result")
     public void afterLiveControllerMethodExecution(JoinPoint joinPoint,Object result) {

+ 19 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveGoodsController.java

@@ -15,6 +15,10 @@ import com.fs.live.domain.LiveGoods;
 import com.fs.live.service.ILiveGoodsService;
 import com.fs.live.vo.LiveGoodsListVo;
 import com.fs.live.vo.LiveGoodsVo;
+import com.fs.store.domain.FsStoreProduct;
+import com.fs.store.service.IFsStoreProductService;
+import com.fs.store.vo.FsStoreProductListVO;
+import com.mysql.cj.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -38,6 +42,9 @@ public class LiveGoodsController extends BaseController
     @Autowired
     private ICompanyUserService companyUserService;
 
+    @Autowired
+    private IFsStoreProductService fsStoreProductService;
+
     /**
      * 查询直播商品列表
      */
@@ -129,6 +136,18 @@ public class LiveGoodsController extends BaseController
         //liveGoods.setCompanyUserId(companyUser.getUserId());
     }
 
+    /**
+     * 查询商品列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:storeProduct:list')")
+    @GetMapping("/liveList")
+    public TableDataInfo liveList(LiveGoods liveGoods)
+    {
+        startPage();
+        List<FsStoreProductListVO> list = fsStoreProductService.liveList(liveGoods);
+        return getDataTable(list);
+    }
+
 
 
     /**

+ 4 - 4
fs-admin/src/main/java/com/fs/live/controller/LiveWatchConfigController.java

@@ -72,10 +72,10 @@ public class LiveWatchConfigController extends BaseController
 //    @PreAuthorize("@ss.hasPermi('live:config:add')")
     @Log(title = "直播观看奖励设置", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody String jsonConfig)
+    public AjaxResult add(@RequestBody String jsonConfig,@RequestParam(value = "liveId") Long liveId)
     {
         String userId = tokenService.getLoginUser(ServletUtils.getRequest()).getUser().getUserId().toString();
-        return toAjax(liveWatchConfigService.insertLiveWatchConfig(userId, jsonConfig));
+        return toAjax(liveWatchConfigService.insertLiveWatchConfig(userId, jsonConfig,liveId));
     }
 
     /**
@@ -84,9 +84,9 @@ public class LiveWatchConfigController extends BaseController
 //    @PreAuthorize("@ss.hasPermi('live:config:edit')")
     @Log(title = "直播观看奖励设置", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody String jsonConfig)
+    public AjaxResult edit(@RequestBody String jsonConfig,@RequestParam(value = "liveId") Long liveId)
     {
-        return toAjax(liveWatchConfigService.updateLiveWatchConfig(jsonConfig));
+        return toAjax(liveWatchConfigService.updateLiveWatchConfig(jsonConfig, liveId));
     }
 
     /**

+ 16 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveGoodsController.java

@@ -14,6 +14,8 @@ import com.fs.live.domain.LiveGoods;
 import com.fs.live.service.ILiveGoodsService;
 import com.fs.live.vo.LiveGoodsListVo;
 import com.fs.live.vo.LiveGoodsVo;
+import com.fs.store.service.IFsStoreProductService;
+import com.fs.store.vo.FsStoreProductListVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -33,6 +35,8 @@ public class LiveGoodsController extends BaseController
 {
     @Autowired
     private ILiveGoodsService liveGoodsService;
+    @Autowired
+    private IFsStoreProductService fsStoreProductService;
 
     /**
      * 查询直播商品列表
@@ -50,6 +54,18 @@ public class LiveGoodsController extends BaseController
         return getDataTable(list);
     }
 
+    /**
+     * 查询商品列表
+     */
+    @PreAuthorize("@ss.hasPermi('store:storeProduct:list')")
+    @GetMapping("/liveList")
+    public TableDataInfo liveList(LiveGoods liveGoods)
+    {
+        startPage();
+        List<FsStoreProductListVO> list = fsStoreProductService.liveList(liveGoods);
+        return getDataTable(list);
+    }
+
     /**
      * 导出直播商品列表
      */

+ 4 - 4
fs-company/src/main/java/com/fs/company/controller/live/LiveWatchConfigController.java

@@ -72,10 +72,10 @@ public class LiveWatchConfigController extends BaseController
 //    @PreAuthorize("@ss.hasPermi('live:config:add')")
     @Log(title = "直播观看奖励设置", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody String jsonConfig)
+    public AjaxResult add(@RequestBody String jsonConfig,@RequestParam(value = "liveId") Long liveId)
     {
         String userId = tokenService.getLoginUser(ServletUtils.getRequest()).getUser().getUserId().toString();
-        return toAjax(liveWatchConfigService.insertLiveWatchConfig(userId, jsonConfig));
+        return toAjax(liveWatchConfigService.insertLiveWatchConfig(userId, jsonConfig, liveId));
     }
 
     /**
@@ -84,9 +84,9 @@ public class LiveWatchConfigController extends BaseController
 //    @PreAuthorize("@ss.hasPermi('live:config:edit')")
     @Log(title = "直播观看奖励设置", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody String jsonConfig)
+    public AjaxResult edit(@RequestBody String jsonConfig,@RequestParam(value = "liveId") Long liveId)
     {
-        return toAjax(liveWatchConfigService.updateLiveWatchConfig(jsonConfig));
+        return toAjax(liveWatchConfigService.updateLiveWatchConfig(jsonConfig,liveId));
     }
 
     /**

+ 1 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveService.java

@@ -185,4 +185,5 @@ public interface ILiveService
     Integer updateLiveIsAudit(Live live);
 
     int updateLiveEntity(Live live);
+
 }

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

@@ -34,7 +34,7 @@ public interface ILiveWatchConfigService {
      * @param jsonConfig 直播观看奖励设置
      * @return 结果
      */
-    int insertLiveWatchConfig(String userId, String jsonConfig);
+    int insertLiveWatchConfig(String userId, String jsonConfig, Long liveId);
 
     /**
      * 修改直播观看奖励设置
@@ -42,7 +42,7 @@ public interface ILiveWatchConfigService {
      * @param jsonConfig 直播观看奖励设置
      * @return 结果
      */
-    int updateLiveWatchConfig(String jsonConfig);
+    int updateLiveWatchConfig(String jsonConfig, Long liveId);
 
     /**
      * 批量删除直播观看奖励设置

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

@@ -349,6 +349,7 @@ public class LiveServiceImpl implements ILiveService
         return baseMapper.updateLive( live);
     }
 
+
     /**
      * 修改直播
      *
@@ -724,24 +725,9 @@ public class LiveServiceImpl implements ILiveService
         // 运营自动化
         List<LiveAutoTask> liveAutoTasksList = liveAutoTaskService.selectLiveAutoTaskByLiveId(existLiveId);
         List<LiveAutoTask> barrageTask = liveAutoTasksList.stream().filter(liveAutoTask -> liveAutoTask.getTaskType() == 3L).collect(Collectors.toList());
-        Map<Long, LiveAutoTask> goodsMap = liveAutoTasksList.stream()
-                .filter(liveAutoTask -> liveAutoTask.getTaskType() == 1L)
-                .collect(Collectors.toMap(liveAutoTask -> {
-                            return parseIdFromContent(liveAutoTask.getContent(),"goodsId");
-                        }, liveAutoTask -> liveAutoTask, (existing, replacement) -> replacement
-                ));
-        Map<Long, LiveAutoTask> redMap = liveAutoTasksList.stream()
-                .filter(liveAutoTask -> liveAutoTask.getTaskType() == 2L)
-                .collect(Collectors.toMap(liveAutoTask -> {
-                    return parseIdFromContent(liveAutoTask.getContent(),"redId");
-                        }, liveAutoTask -> liveAutoTask, (existing, replacement) -> replacement
-                ));
-        Map<Long, LiveAutoTask> lotteryMap = liveAutoTasksList.stream()
-                .filter(liveAutoTask -> liveAutoTask.getTaskType() == 4L)
-                .collect(Collectors.toMap(liveAutoTask -> {
-                    return parseIdFromContent(liveAutoTask.getContent(),"lotteryId");
-                        }, liveAutoTask -> liveAutoTask, (existing, replacement) -> replacement
-                ));
+        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());
         if (!barrageTask.isEmpty()) {
             LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
             for (LiveAutoTask liveAutoTask : barrageTask) {
@@ -751,7 +737,7 @@ public class LiveServiceImpl implements ILiveService
                 liveAutoTaskEntity.setCreateTime(now);
                 liveAutoTaskEntity.setUpdateTime(now);
                 liveAutoTaskEntity.setFinishStatus(0L);
-                liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity,liveEntity);
+                liveAutoTaskService.directInsertLiveAutoTask(liveAutoTaskEntity);
             }
         }
         //直播间红包配置
@@ -766,18 +752,17 @@ public class LiveServiceImpl implements ILiveService
                 liveRedConfEntity.setCreateTime(now);
                 liveRedConfEntity.setTotalSend(0L);
                 liveRedConfService.insertLiveRedConf(liveRedConfEntity);
-                if (redMap.containsKey(liveRedConf.getRedId())) {
-                    LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
-                    LiveAutoTask liveAutoTask = redMap.get(liveRedConf.getRedId());
-                    BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
-                    liveAutoTaskEntity.setId(null);
-                    liveAutoTaskEntity.setLiveId(newLiveId);
-                    liveAutoTaskEntity.setCreateTime(now);
-                    liveAutoTaskEntity.setUpdateTime(now);
-                    liveAutoTaskEntity.setFinishStatus(0L);
-                    liveAutoTaskEntity.setContent(JSON.toJSONString(liveRedConfEntity));
-                    liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity,liveEntity);
-                }
+                LiveAutoTask liveAutoTask = redTaskList.stream().filter(item -> parseIdFromContent(item.getContent(), "redId").equals(liveRedConf.getRedId())).findFirst().orElse(null);
+                if(liveAutoTask == null) continue;
+                LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
+                BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
+                liveAutoTaskEntity.setId(null);
+                liveAutoTaskEntity.setLiveId(newLiveId);
+                liveAutoTaskEntity.setCreateTime(now);
+                liveAutoTaskEntity.setUpdateTime(now);
+                liveAutoTaskEntity.setFinishStatus(0L);
+                liveAutoTaskEntity.setContent(JSON.toJSONString(liveRedConfEntity));
+                liveAutoTaskService.directInsertLiveAutoTask(liveAutoTaskEntity);
             }
         }
         // 直播间礼物配置
@@ -799,18 +784,17 @@ public class LiveServiceImpl implements ILiveService
                             product.setLotteryId(liveLotteryConfEntity.getLotteryId());
                             liveLotteryProductConfMapper.insertLiveLotteryProductConf(product);
                         });
-                if (lotteryMap.containsKey(liveLotteryConf.getLotteryId())) {
-                    LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
-                    LiveAutoTask liveAutoTask = lotteryMap.get(liveLotteryConf.getLotteryId());
-                    BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
-                    liveAutoTaskEntity.setId(null);
-                    liveAutoTaskEntity.setLiveId(newLiveId);
-                    liveAutoTaskEntity.setCreateTime(now);
-                    liveAutoTaskEntity.setUpdateTime(now);
-                    liveAutoTaskEntity.setFinishStatus(0L);
-                    liveAutoTaskEntity.setContent(JSON.toJSONString(liveLotteryConfEntity));
-                    liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity,liveEntity);
-                }
+                LiveAutoTask liveAutoTask = lotteryTaskList.stream().filter(item -> parseIdFromContent(item.getContent(), "lotteryId").equals(liveLotteryConf.getLotteryId())).findFirst().orElse(null);
+                if(liveAutoTask == null) continue;
+                LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
+                BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
+                liveAutoTaskEntity.setId(null);
+                liveAutoTaskEntity.setLiveId(newLiveId);
+                liveAutoTaskEntity.setCreateTime(now);
+                liveAutoTaskEntity.setUpdateTime(now);
+                liveAutoTaskEntity.setFinishStatus(0L);
+                liveAutoTaskEntity.setContent(JSON.toJSONString(liveLotteryConfEntity));
+                liveAutoTaskService.directInsertLiveAutoTask(liveAutoTaskEntity);
             }
         }
         // 直播间商品
@@ -830,19 +814,18 @@ public class LiveServiceImpl implements ILiveService
                 if (collect.containsKey(liveGoods.getGoodsId())) {
                     liveCouponIssueRelations.stream().filter(relation -> relation.getGoodsId().equals(liveGoods.getGoodsId())).findFirst().ifPresent(liveCouponIssueRelation -> liveCouponIssueRelation.setGoodsId(liveGoodsEntity.getGoodsId()));
                 }
-                // 直播商品task
-                if (goodsMap.containsKey(liveGoods.getGoodsId())) {
-                    LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
-                    LiveAutoTask liveAutoTask = goodsMap.get(liveGoods.getGoodsId());
-                    BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
-                    liveAutoTaskEntity.setId(null);
-                    liveAutoTaskEntity.setLiveId(newLiveId);
-                    liveAutoTaskEntity.setCreateTime(now);
-                    liveAutoTaskEntity.setUpdateTime(now);
-                    liveAutoTaskEntity.setFinishStatus(0L);
-                    liveAutoTaskEntity.setContent(JSON.toJSONString(liveGoodsEntity));
-                    liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity,liveEntity);
-                }
+                LiveAutoTask liveAutoTask = goodsTaskList.stream().filter(item -> parseIdFromContent(item.getContent(), "goodsId").equals(liveGoods.getGoodsId())).findFirst().orElse(null);
+                if(liveAutoTask == null) continue;
+                LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
+                BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
+                liveAutoTaskEntity.setId(null);
+                liveAutoTaskEntity.setLiveId(newLiveId);
+                liveAutoTaskEntity.setCreateTime(now);
+                liveAutoTaskEntity.setUpdateTime(now);
+                liveAutoTaskEntity.setFinishStatus(0L);
+                liveAutoTaskEntity.setContent(JSON.toJSONString(liveGoodsEntity));
+                liveAutoTaskService.directInsertLiveAutoTask(liveAutoTaskEntity);
+
             }
         }
         for (LiveCouponIssueRelation liveCouponIssueRelation : liveCouponIssueRelations) {

+ 10 - 9
fs-service-system/src/main/java/com/fs/live/service/impl/LiveWatchConfigServiceImpl.java

@@ -73,18 +73,17 @@ public class LiveWatchConfigServiceImpl implements ILiveWatchConfigService {
      * @return 结果
      */
     @Override
-    public int insertLiveWatchConfig(String userId, String jsonConfig)
+    public int insertLiveWatchConfig(String userId, String jsonConfig ,Long liveId)
     {
-        LiveWatchConfig liveWatchConfig = JSON.parseObject(jsonConfig, LiveWatchConfig.class);
-        Live live = liveService.selectLiveByLiveId(liveWatchConfig.getLiveId());
+        Live live = liveService.selectLiveByLiveId(liveId);
         if(live == null){
             return 0;
         }
         JSONObject jsonObject = JSON.parseObject(jsonConfig);
-        jsonObject.put("id", live.getLiveId());
+        jsonObject.put("liveId", live.getLiveId());
         jsonConfig = jsonObject.toJSONString();
         live.setConfigJson(jsonConfig);
-        return liveService.updateLive(live);
+        return liveService.updateLiveEntity(live);
     }
 
     /**
@@ -94,15 +93,17 @@ public class LiveWatchConfigServiceImpl implements ILiveWatchConfigService {
      * @return 结果
      */
     @Override
-    public int updateLiveWatchConfig(String jsonConfig)
+    public int updateLiveWatchConfig(String jsonConfig, Long liveId)
     {
-        LiveWatchConfig liveWatchConfig = JSON.parseObject(jsonConfig, LiveWatchConfig.class);
-        Live live = liveService.selectLiveByLiveId(liveWatchConfig.getLiveId());
+        Live live = liveService.selectLiveByLiveId(liveId);
         if(live == null){
             return 0;
         }
+        JSONObject jsonObject = JSON.parseObject(jsonConfig);
+        jsonObject.put("liveId", live.getLiveId());
+        jsonConfig = jsonObject.toJSONString();
         live.setConfigJson(jsonConfig);
-        return liveService.updateLive(live);
+        return liveService.updateLiveEntity(live);
     }
 
     /**

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

@@ -22,7 +22,7 @@ public class LiveGoodsVo {
     // 是否收藏
     private Boolean isFavorite;
     private Boolean isShow;
-    private Long barCode;
+    private String barCode;
 
     /**
      * 仓库代码

+ 15 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreProductMapper.java

@@ -3,6 +3,7 @@ package com.fs.store.mapper;
 import java.util.List;
 import java.util.Map;
 
+import com.fs.live.domain.LiveGoods;
 import com.fs.store.domain.FsStoreProduct;
 import com.fs.store.param.FsStoreProductQueryParam;
 import com.fs.store.vo.*;
@@ -224,4 +225,18 @@ public interface FsStoreProductMapper
             "select * from fs_store_product where find_in_set(product_id,#{ids})  " +
             "</script>"})
     List<FsStoreProduct> selectProductByIds(@Param("ids") String productsId);
+
+    @Select({"<script> " +
+            "SELECT fsp.* FROM fs_store_product fsp " +
+            " left join fs_store_product_attr_value fspav on fsp.product_id = fspav.product_id  " +
+            "WHERE fsp.is_show = 1 and (fspav.bar_code is not null or fspav.group_bar_code is not null)  and " +
+            " fsp.product_id NOT IN (" +
+            "   SELECT product_id FROM live_goods " +
+            "   WHERE live_id = #{maps.liveId} " +
+            ")  " +
+            "<if test = 'maps.keywords != null'> " +
+            " and  fsp.product_name like CONCAT('%',#{maps.keywords},'%')  " +
+            "</if>" +
+            "</script>"})
+    List<FsStoreProductListVO> liveList(@Param("maps") LiveGoods maps);
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStoreProductService.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.fs.common.core.domain.R;
+import com.fs.live.domain.LiveGoods;
 import com.fs.store.domain.FsStoreProduct;
 import com.fs.store.param.FsStoreProductAddEditParam;
 import com.fs.store.param.FsStoreProductQueryParam;
@@ -110,4 +111,6 @@ public interface IFsStoreProductService
     Integer updateFsStoreProductIsShow(Long[] productIds, int status);
 
     List<FsStoreProduct> selectProductByIds(String productsId);
+
+    List<FsStoreProductListVO> liveList(LiveGoods liveId);
 }

+ 6 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreProductServiceImpl.java

@@ -15,6 +15,7 @@ import com.fs.common.BeanCopyUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
+import com.fs.live.domain.LiveGoods;
 import com.fs.store.domain.*;
 import com.fs.store.dto.ProductArrtDTO;
 import com.fs.store.dto.ProductAttrCountDto;
@@ -747,4 +748,9 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     public List<FsStoreProduct> selectProductByIds(String productsId) {
         return fsStoreProductMapper.selectProductByIds(productsId);
     }
+
+    @Override
+    public List<FsStoreProductListVO> liveList(LiveGoods liveId) {
+        return fsStoreProductMapper.liveList(liveId);
+    }
 }

+ 3 - 1
fs-service-system/src/main/resources/mapper/live/LiveGoodsMapper.xml

@@ -256,8 +256,10 @@ 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.image as img_url,sp.product_name,sp.price,sp.stock,sp.sales,sp.product_id,sp.ot_price, sp.is_show as fs_status,sp.bar_code
+        select sp.image as img_url,sp.product_name,sp.price,sp.stock,sp.sales,sp.product_id,sp.ot_price, sp.is_show as fs_status,pav.bar_code
         from fs_store_product sp
+        left join fs_store_product_attr_value pav
+        ON  sp.product_id = pav.product_id
         <where>
             sp.product_id = #{productId}
         </where>