Quellcode durchsuchen

直播代码提交 自动建群功能

yuhongqi vor 1 Woche
Ursprung
Commit
98823aaf22
64 geänderte Dateien mit 1164 neuen und 294 gelöschten Zeilen
  1. 46 0
      fs-admin/src/main/java/com/fs/live/aspectj/LiveControllerAspect.java
  2. 17 1
      fs-admin/src/main/java/com/fs/live/controller/LiveGoodsController.java
  3. 7 7
      fs-admin/src/main/java/com/fs/live/controller/LiveUserLotteryRecordController.java
  4. 4 4
      fs-admin/src/main/java/com/fs/live/controller/LiveWatchConfigController.java
  5. 12 5
      fs-admin/src/main/java/com/fs/live/controller/LiveWatchUserController.java
  6. 45 0
      fs-company/src/main/java/com/fs/company/aspectj/LiveControllerAspect.java
  7. 19 0
      fs-company/src/main/java/com/fs/company/controller/live/LiveGoodsController.java
  8. 4 4
      fs-company/src/main/java/com/fs/company/controller/live/LiveWatchConfigController.java
  9. 11 5
      fs-company/src/main/java/com/fs/company/controller/live/LiveWatchUserController.java
  10. 0 2
      fs-company/src/main/java/com/fs/framework/service/UserDetailsServiceImpl.java
  11. 2 2
      fs-live-app/src/main/java/com/fs/live/controller/LiveController.java
  12. 29 0
      fs-live-app/src/main/java/com/fs/live/controller/LiveDataController.java
  13. 8 4
      fs-live-app/src/main/java/com/fs/live/task/Task.java
  14. 2 0
      fs-live-app/src/main/java/com/fs/live/vo/LotteryVo.java
  15. 86 2
      fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java
  16. 16 0
      fs-service/src/main/java/com/fs/his/mapper/FsStoreProductMapper.java
  17. 4 0
      fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java
  18. 4 0
      fs-service/src/main/java/com/fs/his/service/IFsStoreProductService.java
  19. 7 0
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreProductServiceImpl.java
  20. 18 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java
  21. 5 0
      fs-service/src/main/java/com/fs/hisStore/mapper/FsUserAddressScrmMapper.java
  22. 3 0
      fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductScrmService.java
  23. 4 1
      fs-service/src/main/java/com/fs/hisStore/service/IFsUserAddressScrmService.java
  24. 6 0
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java
  25. 13 7
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserAddressScrmServiceImpl.java
  26. 2 1
      fs-service/src/main/java/com/fs/live/domain/LiveGoods.java
  27. 1 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrder.java
  28. 7 0
      fs-service/src/main/java/com/fs/live/domain/LiveUserLotteryRecord.java
  29. 3 0
      fs-service/src/main/java/com/fs/live/domain/LiveWatchUser.java
  30. 2 0
      fs-service/src/main/java/com/fs/live/dto/LiveOrderItemDTO.java
  31. 6 1
      fs-service/src/main/java/com/fs/live/mapper/LiveAutoTaskMapper.java
  32. 2 2
      fs-service/src/main/java/com/fs/live/mapper/LiveCouponMapper.java
  33. 1 1
      fs-service/src/main/java/com/fs/live/mapper/LiveLotteryConfMapper.java
  34. 3 3
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java
  35. 1 1
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java
  36. 12 0
      fs-service/src/main/java/com/fs/live/mapper/LiveUserLotteryRecordMapper.java
  37. 11 2
      fs-service/src/main/java/com/fs/live/mapper/LiveWatchUserMapper.java
  38. 2 0
      fs-service/src/main/java/com/fs/live/service/ILiveAutoTaskService.java
  39. 6 0
      fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java
  40. 3 2
      fs-service/src/main/java/com/fs/live/service/ILiveWatchConfigService.java
  41. 4 1
      fs-service/src/main/java/com/fs/live/service/ILiveWatchUserService.java
  42. 44 7
      fs-service/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java
  43. 7 5
      fs-service/src/main/java/com/fs/live/service/impl/LiveGoodsServiceImpl.java
  44. 285 75
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  45. 78 63
      fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java
  46. 10 9
      fs-service/src/main/java/com/fs/live/service/impl/LiveWatchConfigServiceImpl.java
  47. 43 2
      fs-service/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java
  48. 1 1
      fs-service/src/main/java/com/fs/live/vo/LiveGoodsVo.java
  49. 2 0
      fs-service/src/main/java/com/fs/live/vo/LiveUserLotteryRecordVo.java
  50. 11 0
      fs-service/src/main/java/com/fs/live/vo/LiveWatchUserStatistics.java
  51. 6 0
      fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml
  52. 58 4
      fs-service/src/main/resources/mapper/live/LiveAutoTaskMapper.xml
  53. 2 2
      fs-service/src/main/resources/mapper/live/LiveCartMapper.xml
  54. 20 18
      fs-service/src/main/resources/mapper/live/LiveGoodsMapper.xml
  55. 7 8
      fs-service/src/main/resources/mapper/live/LiveLotteryProductConfMapper.xml
  56. 2 2
      fs-service/src/main/resources/mapper/live/LiveOrderItemMapper.xml
  57. 13 13
      fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml
  58. 19 10
      fs-service/src/main/resources/mapper/live/LiveUserLotteryRecordMapper.xml
  59. 23 14
      fs-service/src/main/resources/mapper/live/LiveWatchUserMapper.xml
  60. 1 1
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveAfterSalesController.java
  61. 1 1
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveController.java
  62. 2 1
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveGoodsController.java
  63. 73 0
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java
  64. 18 0
      fs-user-app/src/main/java/com/fs/app/controller/store/AddressScrmController.java

+ 46 - 0
fs-admin/src/main/java/com/fs/live/aspectj/LiveControllerAspect.java

@@ -0,0 +1,46 @@
+package com.fs.live.aspectj;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.fs.live.domain.Live;
+import com.fs.live.service.ILiveService;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Aspect
+@Component
+public class LiveControllerAspect {
+
+    private static final Logger logger = LoggerFactory.getLogger(LiveControllerAspect.class);
+
+    @Autowired
+    private ILiveService liveService;
+
+    @AfterReturning(pointcut = "execution(* com.fs.live.controller.LiveController.add(..)) || " +
+            "execution(* com.fs.live.controller.LiveController.finishLive(..)) || " +
+            "execution(* com.fs.live.controller.LiveController.handleDeleteSelected(..)) || " +
+            "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) {
+        String methodName = joinPoint.getSignature().getName();
+        Object[] args = joinPoint.getArgs();
+        liveService.asyncToCache();
+        if (args[0] instanceof Live) {
+            Live live = (Live) args[0];
+            if (ObjectUtil.isNotEmpty(live) && ObjectUtil.isNotEmpty(live.getLiveId())){
+                liveService.asyncToCacheLiveDetail(live.getLiveId());
+            }
+        }
+        logger.info("后台直播间列表变更");
+
+    }
+}

+ 17 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveGoodsController.java

@@ -10,11 +10,14 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.hisStore.service.IFsStoreProductScrmService;
+import com.fs.hisStore.vo.FsStoreProductListVO;
 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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -33,6 +36,9 @@ public class LiveGoodsController extends BaseController
     @Autowired
     private ILiveGoodsService liveGoodsService;
 
+    @Autowired
+    private IFsStoreProductScrmService fsStoreProductService;
+
 
     /**
      * 查询直播商品列表
@@ -125,7 +131,17 @@ 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);
+    }
 
     /**
      * 获取直播店铺

+ 7 - 7
fs-admin/src/main/java/com/fs/live/controller/LiveUserLotteryRecordController.java

@@ -31,7 +31,7 @@ public class LiveUserLotteryRecordController extends BaseController
     /**
      * 查询直播用户中奖记录列表
      */
-    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:list')")
+//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:list')")
     @GetMapping("/list")
     public TableDataInfo list(LiveUserLotteryRecord liveUserLotteryRecord)
     {
@@ -43,7 +43,7 @@ public class LiveUserLotteryRecordController extends BaseController
     /**
      * 导出直播用户中奖记录列表
      */
-    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:export')")
+//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:export')")
     @Log(title = "直播用户中奖记录", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(LiveUserLotteryRecord liveUserLotteryRecord)
@@ -56,7 +56,7 @@ public class LiveUserLotteryRecordController extends BaseController
     /**
      * 获取直播用户中奖记录详细信息
      */
-    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:query')")
+//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
@@ -66,7 +66,7 @@ public class LiveUserLotteryRecordController extends BaseController
     /**
      * 新增直播用户中奖记录
      */
-    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:add')")
+//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:add')")
     @Log(title = "直播用户中奖记录", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody LiveUserLotteryRecord liveUserLotteryRecord)
@@ -77,7 +77,7 @@ public class LiveUserLotteryRecordController extends BaseController
     /**
      * 修改直播用户中奖记录
      */
-    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:edit')")
+//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:edit')")
     @Log(title = "直播用户中奖记录", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody LiveUserLotteryRecord liveUserLotteryRecord)
@@ -88,7 +88,7 @@ public class LiveUserLotteryRecordController extends BaseController
     /**
      * 删除直播用户中奖记录
      */
-    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:remove')")
+//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:remove')")
     @Log(title = "直播用户中奖记录", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)
@@ -99,7 +99,7 @@ public class LiveUserLotteryRecordController extends BaseController
     /**
      * 查询直播用户中奖记录列表
      */
-    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:list')")
+//    @PreAuthorize("@ss.hasPermi('live:liveUserLotteryRecord:list')")
     @PostMapping("/info")
     public R info(@RequestBody LiveUserLotteryRecord liveUserLotteryRecord)
     {

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

@@ -71,10 +71,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));
     }
 
     /**
@@ -83,9 +83,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));
     }
 
     /**

+ 12 - 5
fs-admin/src/main/java/com/fs/live/controller/LiveWatchUserController.java

@@ -3,6 +3,7 @@ package com.fs.live.controller;
 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.utils.poi.ExcelUtil;
@@ -42,13 +43,19 @@ public class LiveWatchUserController extends BaseController
         return getDataTable(list);
     }
 
-//    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:list')")
+    @GetMapping("/liveUserTotals")
+    public R liveUserTotals(LiveWatchUser liveWatchUser)
+    {
+
+        return liveWatchUserService.liveUserTotals(liveWatchUser);
+    }
+
+    //    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:list')")
     @GetMapping("/watchUserList")
-    public TableDataInfo watchUserList(@RequestParam Long liveId) {
-        Map<String, Object> params = new HashMap<>();
-        params.put("liveId", liveId);
+    public TableDataInfo watchUserList(@RequestParam Map<String,Object> param) {
+
         startPage();
-        List<LiveWatchUserVO> onLineUserList = liveWatchUserService.selectWatchUserList(params);
+        List<LiveWatchUserVO> onLineUserList = liveWatchUserService.selectWatchUserList(param);
         return getDataTable(onLineUserList);
     }
 

+ 45 - 0
fs-company/src/main/java/com/fs/company/aspectj/LiveControllerAspect.java

@@ -0,0 +1,45 @@
+package com.fs.company.aspectj;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.fs.live.domain.Live;
+import com.fs.live.service.ILiveService;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Aspect
+@Component
+public class LiveControllerAspect {
+
+    private static final Logger logger = LoggerFactory.getLogger(LiveControllerAspect.class);
+
+    @Autowired
+    private ILiveService liveService;
+
+    @AfterReturning(pointcut = "execution(* com.fs.company.controller.live.LiveController.add(..)) || " +
+            "execution(* com.fs.company.controller.live.LiveController.finishLive(..)) || " +
+            "execution(* com.fs.company.controller.live.LiveController.copyLive(..)) || " +
+            "execution(* com.fs.company.controller.live.LiveController.handleShelfOrUn(..)) || " +
+            "execution(* com.fs.company.controller.live.LiveController.handleDeleteSelected(..)) || " +
+            "execution(* com.fs.company.controller.live.LiveController.edit(..)) || " +
+            "execution(* com.fs.company.controller.live.LiveController.remove(..)) || " +
+            "execution(* com.fs.company.controller.live.LiveController.startLive(..))",
+            returning = "result")
+    public void afterLiveControllerMethodExecution(JoinPoint joinPoint,Object result) {
+        String methodName = joinPoint.getSignature().getName();
+        Object[] args = joinPoint.getArgs();
+        liveService.asyncToCache();
+        if (args[0] instanceof Live) {
+            Live live = (Live) args[0];
+            if (ObjectUtil.isNotEmpty(live) && ObjectUtil.isNotEmpty(live.getLiveId())){
+                liveService.asyncToCacheLiveDetail(live.getLiveId());
+            }
+        }
+        logger.info("后台直播间列表变更");
+
+    }
+}

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

@@ -10,11 +10,15 @@ import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.domain.CompanyUser;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.security.SecurityUtils;
+import com.fs.his.service.IFsStoreProductService;
+import com.fs.hisStore.service.IFsStoreProductScrmService;
+import com.fs.hisStore.vo.FsStoreProductListVO;
 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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -33,6 +37,9 @@ public class LiveGoodsController extends BaseController
     @Autowired
     private ILiveGoodsService liveGoodsService;
 
+    @Autowired
+    private IFsStoreProductScrmService fsStoreProductService;
+
     /**
      * 查询直播商品列表
      */
@@ -49,6 +56,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

@@ -71,10 +71,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));
     }
 
     /**
@@ -83,9 +83,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));
     }
 
     /**

+ 11 - 5
fs-company/src/main/java/com/fs/company/controller/live/LiveWatchUserController.java

@@ -3,6 +3,7 @@ package com.fs.company.controller.live;
 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.utils.poi.ExcelUtil;
@@ -42,14 +43,19 @@ public class LiveWatchUserController extends BaseController
         return getDataTable(list);
     }
 
-//    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:list')")
+    @GetMapping("/liveUserTotals")
+    public R liveUserTotals(LiveWatchUser liveWatchUser)
+    {
+
+        return liveWatchUserService.liveUserTotals(liveWatchUser);
+    }
+
+    //    @PreAuthorize("@ss.hasPermi('live:liveWatchUser:list')")
     @GetMapping("/watchUserList")
-    public TableDataInfo watchUserList(@RequestParam Long liveId) {
-        Map<String, Object> params = new HashMap<>();
-        params.put("liveId", liveId);
+    public TableDataInfo watchUserList(@RequestParam Map<String,Object> param) {
 
         startPage();
-        List<LiveWatchUserVO> onLineUserList = liveWatchUserService.selectWatchUserList(params);
+        List<LiveWatchUserVO> onLineUserList = liveWatchUserService.selectWatchUserList(param);
         return getDataTable(onLineUserList);
     }
 

+ 0 - 2
fs-company/src/main/java/com/fs/framework/service/UserDetailsServiceImpl.java

@@ -46,8 +46,6 @@ public class UserDetailsServiceImpl implements UserDetailsService
 
 
         CompanyUser user = userService.selectUserByUserName(username);
-        // todo yhq
-        user.setPassword(SecurityUtils.encryptPassword("admin1122.."));
         if (StringUtils.isNull(user))
         {
             log.info("登录用户:{} 不存在.", username);

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

@@ -36,7 +36,7 @@ import java.util.*;
 
 
 @Api("直播信息接口")
-@RestController
+@RestController("wsAppLiveController")
 @AllArgsConstructor
 @RequestMapping(value="/ws/app/live")
 public class LiveController {
@@ -77,7 +77,7 @@ public class LiveController {
 		live.setLiveId(Long.valueOf(params.get("stream_id")));
 		live.setStatus(3);
 		live.setFinishTime(LocalDateTime.now());
-		liveService.updateLive(live);
+		liveService.updateLiveEntity(live);
 		return R.ok();
 //		{app=200149.push.tlivecloud.com, appid=1319721001, appname=live, channel_id=673,
 //				errcode=1, errmsg=The push client actively stopped the push, event_time=1755571239,

+ 29 - 0
fs-live-app/src/main/java/com/fs/live/controller/LiveDataController.java

@@ -0,0 +1,29 @@
+package com.fs.live.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.redis.RedisCache;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/app/live/liveData")
+public class LiveDataController extends BaseController {
+
+    @Autowired
+    private RedisCache redisCache;
+
+    /**
+     * 点赞
+     * */
+    @GetMapping("/like/{liveId}")
+    public R like(@PathVariable("liveId") Long liveId) {
+        //直播间总点赞数
+        Long increment = redisCache.incr("live:like:" + liveId, 1);
+
+        return R.ok().put("like",increment);
+    }
+}

+ 8 - 4
fs-live-app/src/main/java/com/fs/live/task/Task.java

@@ -34,6 +34,7 @@ import java.math.BigDecimal;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static com.fs.common.constant.LiveKeysConstant.*;
@@ -155,7 +156,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);
+                        redisCache.redisTemplate.expire(key+live.getLiveId(), 1, TimeUnit.DAYS);
                     });
                 }
             }
@@ -174,6 +175,7 @@ public class Task {
                         redisCache.redisTemplate.opsForZSet().remove(key + live.getLiveId(), JSON.toJSONString(liveAutoTask),liveAutoTask.getAbsValue().getTime());
                     });
                 }
+                webSocketServer.removeLikeCountCache(live.getLiveId());
             }
         }
         if(!liveList.isEmpty()){
@@ -253,7 +255,7 @@ public class Task {
             }
 
             // 查询在线用户 并且参与了抽奖的用户
-            List<LiveWatchUser> liveWatchUsers = liveWatchUserService.selectLiveWatchAndRegisterUser(liveLottery.getLiveId(),liveLottery.getLotteryId(), totalLots);
+            List<LiveWatchUser> liveWatchUsers = liveWatchUserService.selectLiveWatchAndRegisterUser(liveLottery.getLiveId(),liveLottery.getLotteryId());
             if(liveWatchUsers.isEmpty()) continue;
             LiveLotteryRegistration liveLotteryRegistration;
             // 收集中奖信息
@@ -273,6 +275,7 @@ public class Task {
                     record.setUserId(winningUser.getUserId());
                     record.setProductId(liveLotteryProductListVo.getProductId());
                     record.setCreateTime(new Date());
+                    record.setOrderStatus(-9);
 
                     // 保存中奖记录
                     liveUserLotteryRecordService.insertLiveUserLotteryRecord(record);
@@ -291,6 +294,7 @@ public class Task {
                     lotteryVo.setUserName(winningUser.getNickName());
                     lotteryVo.setPrizeLevel(liveLotteryProductListVo.getPrizeLevel());
                     lotteryVo.setProductName(liveLotteryProductListVo.getProductName());
+                    lotteryVo.setProductId(liveLotteryProductListVo.getProductId());
                     lotteryVos.add(lotteryVo);
                 }
             }
@@ -359,7 +363,7 @@ public class Task {
             if (config.getEnabled()) {
                 // 3.检查当前直播间的在线用户(可以传入一个时间,然后查出来当天没领取奖励的用户)
                 List<LiveWatchUser> onlineUser = liveWatchUserService.checkOnlineNoRewardUser(openRewardLive.getLiveId(), now)
-                        .stream().filter(user -> now.getTime() - user.getUpdateTime().getTime() > config.getWatchDuration() * 60 * 1000)
+                        .stream().filter(user -> (now.getTime() - user.getUpdateTime().getTime() + ( user.getOnlineSeconds() == null ? 0L : user.getOnlineSeconds())) > config.getWatchDuration() * 60 * 1000)
                         .collect(Collectors.toList());
                 if(onlineUser.isEmpty()) continue;
 
@@ -380,7 +384,7 @@ public class Task {
             record.setLiveId(live.getLiveId());
             record.setUserId(userId);
             record.setIncomeType(1L);
-            record.setSourceType(1L);
+            record.setSourceType(3L);
             record.setSourceId(live.getCompanyId() == null ? 0L : live.getCompanyId());
             record.setRewardType(2L);
             record.setNum(BigDecimal.valueOf(scoreAmount));

+ 2 - 0
fs-live-app/src/main/java/com/fs/live/vo/LotteryVo.java

@@ -13,5 +13,7 @@ public class LotteryVo {
     private Long userId;
     private String productName;
     private Long prizeLevel;
+    private Long productId;
+    private Long recordId;
 
 }

+ 86 - 2
fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -28,6 +28,7 @@ import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
 
 import static com.fs.common.constant.LiveKeysConstant.*;
@@ -37,6 +38,9 @@ import static com.fs.common.constant.LiveKeysConstant.*;
 @Slf4j
 public class WebSocketServer {
 
+
+    // 上次点赞数缓存
+    private final ConcurrentHashMap<Long, Integer> lastLikeCountCache = new ConcurrentHashMap<>();
     // 直播间用户session
     private final static ConcurrentHashMap<Long, ConcurrentHashMap<Long, Session>> rooms = new ConcurrentHashMap<>();
     // 管理端连接
@@ -415,16 +419,88 @@ public class WebSocketServer {
 
         room.forEach((k, v) -> {
             if (v.isOpen()) {
-                v.getAsyncRemote().sendText(message);
+                sendWithRetry(v,message,7);
             }
         });
         adminRoom.forEach(v -> {
             if (v.isOpen()) {
-                v.getAsyncRemote().sendText(message);
+                sendWithRetry(v,message,7);
             }
         });
     }
 
+    public void removeLikeCountCache(Long liveId) {
+        lastLikeCountCache.remove(liveId);
+    }
+    @Scheduled(fixedRate = 300)// 每分钟执行一次
+    public void broadcastLikeMessage() {
+        Set<Long> activeLiveIds = new HashSet<>();
+        for (Map.Entry<Long, ConcurrentHashMap<Long, Session>> entry : rooms.entrySet()) {
+            Long liveId = entry.getKey();
+            activeLiveIds.add(liveId);
+            String likeKey = "live:like:" + liveId;
+            Object cacheObject = redisCache.getCacheObject(likeKey);
+            if(cacheObject == null) continue;
+            Integer current = null;
+            try {
+                String valueStr = cacheObject.toString().trim();
+                current = Integer.parseInt(valueStr);
+            } catch (NumberFormatException e) {
+                log.error("点赞数格式错误,liveId: {}, value: {}", liveId, cacheObject, e);
+                continue;
+            }
+            Integer last = lastLikeCountCache.getOrDefault(liveId, 0);
+            if (!current.equals(last)) {
+                SendMsgVo sendMsgVo = new SendMsgVo();
+                sendMsgVo.setLiveId(liveId);
+                sendMsgVo.setCmd("likeDetail");
+                sendMsgVo.setData(JSON.toJSONString(current));
+                broadcastLikeMessage(liveId, JSONObject.toJSONString(R.ok().put("data",sendMsgVo)));
+                lastLikeCountCache.put(liveId, current); // 更新上次值
+            }
+        }
+        lastLikeCountCache.keySet().removeIf(liveId -> !activeLiveIds.contains(liveId));
+    }
+
+    /**
+     * 广播点赞消息
+     * @param liveId   直播间ID
+     * @param message  消息内容
+     */
+    public void broadcastLikeMessage(Long liveId, String message) {
+        ConcurrentHashMap<Long, Session> room = getRoom(liveId);
+        room.forEach((k, v) -> {
+            if (v.isOpen()) {
+                sendWithRetry(v,message,7);
+            }
+        });
+    }
+
+    private void sendWithRetry(Session session, String message, int maxRetries) {
+        int attempts = 0;
+        while (attempts < maxRetries) {
+            try {
+                if(session.isOpen()) {
+                    session.getAsyncRemote().sendText(message);
+                }
+                return;  // 发送成功,退出
+            } catch (Exception e) {
+                if (e.getMessage() != null && e.getMessage().contains("TEXT_FULL_WRITING")) {
+                    attempts++;
+                    try {
+                        TimeUnit.MILLISECONDS.sleep(ThreadLocalRandom.current().nextInt(5, 100));
+                    } catch (InterruptedException ie) {
+                        Thread.currentThread().interrupt();
+                        break;
+                    }
+                } else {
+                    throw e;
+                }
+            }
+        }
+        log.info("超过重试次数, 消息 {}",message);
+    }
+
 
 
     public void handleAutoTask(LiveAutoTask task) {
@@ -440,6 +516,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));
@@ -447,6 +527,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));

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

@@ -6,6 +6,8 @@ import com.fs.his.domain.FsStoreProductRule;
 import com.fs.his.param.FsProductAttrValueParam;
 import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.vo.*;
+import com.fs.hisStore.vo.FsStoreProductListVO;
+import com.fs.live.domain.LiveGoods;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -265,4 +267,18 @@ public interface FsStoreProductMapper {
      * @return List<FsStoreProduct>
      * **/
     List<FsStoreProduct> getStoreProductInProductIds(@Param("productIds") List<Long> productIds);
+
+    @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);
 }

+ 4 - 0
fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java

@@ -417,4 +417,8 @@ public interface FsUserMapper
             "</foreach>" +
             " </script>"})
     void incrIntegral(@Param("userIds") List<Long> userIds,@Param("scoreAmount") Long scoreAmount);
+
+    @Update("update fs_user set pay_count=pay_count+1" +
+            " where user_id=#{userId}")
+    void incPayCount(Long aLong);
 }

+ 4 - 0
fs-service/src/main/java/com/fs/his/service/IFsStoreProductService.java

@@ -10,6 +10,8 @@ import com.fs.his.param.FsProductAttrValueParam;
 import com.fs.his.param.FsStoreProductAddEditParam;
 import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.vo.*;
+import com.fs.hisStore.vo.FsStoreProductListVO;
+import com.fs.live.domain.LiveGoods;
 
 /**
  * 商品Service接口
@@ -104,4 +106,6 @@ public interface IFsStoreProductService
      * @return List<FsStoreProduct>
      * **/
     List<FsStoreProduct> getStoreProductInProductIds(List<Long> productIds);
+
+    List<FsStoreProductListVO> liveList(LiveGoods liveId);
 }

+ 7 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStoreProductServiceImpl.java

@@ -34,6 +34,8 @@ import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.service.IFsPackageService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.*;
+import com.fs.hisStore.vo.FsStoreProductListVO;
+import com.fs.live.domain.LiveGoods;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -870,4 +872,9 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService {
     public List<FsStoreProduct> getStoreProductInProductIds(List<Long> productIds) {
         return fsStoreProductMapper.getStoreProductInProductIds(productIds);
     }
+
+    @Override
+    public List<FsStoreProductListVO> liveList(LiveGoods liveId) {
+        return fsStoreProductMapper.liveList(liveId);
+    }
 }

+ 18 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java

@@ -3,11 +3,13 @@ package com.fs.hisStore.mapper;
 import java.util.List;
 import java.util.Map;
 
+import com.fs.his.domain.FsStoreProduct;
 import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.vo.FsStoreProductListSVO;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.FsStoreProductRuleScrm;
+import com.fs.live.domain.LiveGoods;
 import com.fs.statis.dto.ModifyMoreDTO;
 import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.param.FsStoreProductQueryParam;
@@ -375,4 +377,20 @@ public interface FsStoreProductScrmMapper
     List<FsStoreProductActivityListVO> selectFsStoreProductByIdsAudit(String productIds,@Param("config") MedicalMallConfig  config);
 
     List<FsStoreProductScrm> bulkCopyFsStoreProductByIds(Long[] productIds);
+
+    @Select({"<script> " +
+            "SELECT fsp.* FROM fs_store_product_scrm fsp " +
+            " left join fs_store_product_attr_value_scrm fspav on fsp.product_id = fspav.product_id  " +
+            "WHERE fsp.is_show = 1 and (fspav.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);
+
+    List<FsStoreProductScrm> selectFsStoreProductByProductIds(@Param("productIds") List<Long> productIdsLong);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserAddressScrmMapper.java

@@ -1,6 +1,8 @@
 package com.fs.hisStore.mapper;
 
 import java.util.List;
+
+import com.fs.his.domain.FsUserAddress;
 import com.fs.hisStore.domain.FsUserAddressScrm;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -68,4 +70,7 @@ public interface FsUserAddressScrmMapper
     Integer selectFsUserAddressCountsByUserId(long userId);
     @Update(" update fs_user_address set is_del=1 where user_id = #{userId}")
     Integer delAllAddress(Long userId);
+
+    @Select("select * from fs_user_address where user_id=#{uid} and is_default=1 and is_del=0 limit 1")
+    FsUserAddress selectFsUserAddressByDefault(long userId);
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductScrmService.java

@@ -11,6 +11,7 @@ import com.fs.his.vo.FsStoreProductExcelVO;
 import com.fs.his.vo.FsStoreProductListSVO;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.vo.*;
+import com.fs.live.domain.LiveGoods;
 import com.fs.statis.dto.ModifyMoreDTO;
 import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.param.FsStoreProductAddEditParam;
@@ -137,4 +138,6 @@ public interface IFsStoreProductScrmService
     List<FsStoreProductActivityListVO> selectFsStoreProductByIdsAudit(String productIds);
 
     R bulkCopyFsStoreProductByIds(Long[] productIds);
+
+    List<FsStoreProductListVO> liveList(LiveGoods liveId);
 }

+ 4 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsUserAddressScrmService.java

@@ -1,12 +1,13 @@
 package com.fs.hisStore.service;
 
+import com.fs.his.domain.FsUserAddress;
 import com.fs.hisStore.domain.FsUserAddressScrm;
 
 import java.util.List;
 
 /**
  * 用户地址Service接口
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
@@ -67,4 +68,6 @@ public interface IFsUserAddressScrmService
     Integer delAllAddress(Long userId);
 
     String getKdnAddress(String address);
+
+    FsUserAddress selectFsUserAddressByDefault(long l);
 }

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -30,6 +30,7 @@ import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.utils.StoreAuditLogUtil;
+import com.fs.live.domain.LiveGoods;
 import com.fs.statis.dto.ModifyMoreDTO;
 import com.fs.hisStore.dto.ProductArrtDTO;
 import com.fs.hisStore.dto.ProductAttrCountDto;
@@ -1152,4 +1153,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         }
         return R.ok();
     }
+
+    @Override
+    public List<FsStoreProductListVO> liveList(LiveGoods liveId) {
+        return fsStoreProductMapper.liveList(liveId);
+    }
 }

+ 13 - 7
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserAddressScrmServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.http.HttpUtil;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.his.config.FsSysConfig;
+import com.fs.his.domain.FsUserAddress;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.hisStore.domain.FsUserAddressScrm;
 import com.fs.hisStore.mapper.FsUserAddressScrmMapper;
@@ -20,7 +21,7 @@ import java.util.Map;
 
 /**
  * 用户地址Service业务层处理
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
@@ -34,7 +35,7 @@ public class FsUserAddressScrmServiceImpl implements IFsUserAddressScrmService
 
     /**
      * 查询用户地址
-     * 
+     *
      * @param id 用户地址ID
      * @return 用户地址
      */
@@ -46,7 +47,7 @@ public class FsUserAddressScrmServiceImpl implements IFsUserAddressScrmService
 
     /**
      * 查询用户地址列表
-     * 
+     *
      * @param fsUserAddress 用户地址
      * @return 用户地址
      */
@@ -58,7 +59,7 @@ public class FsUserAddressScrmServiceImpl implements IFsUserAddressScrmService
 
     /**
      * 新增用户地址
-     * 
+     *
      * @param fsUserAddress 用户地址
      * @return 结果
      */
@@ -72,7 +73,7 @@ public class FsUserAddressScrmServiceImpl implements IFsUserAddressScrmService
 
     /**
      * 修改用户地址
-     * 
+     *
      * @param fsUserAddress 用户地址
      * @return 结果
      */
@@ -86,7 +87,7 @@ public class FsUserAddressScrmServiceImpl implements IFsUserAddressScrmService
 
     /**
      * 批量删除用户地址
-     * 
+     *
      * @param ids 需要删除的用户地址ID
      * @return 结果
      */
@@ -98,7 +99,7 @@ public class FsUserAddressScrmServiceImpl implements IFsUserAddressScrmService
 
     /**
      * 删除用户地址信息
-     * 
+     *
      * @param id 用户地址ID
      * @return 结果
      */
@@ -143,6 +144,11 @@ public class FsUserAddressScrmServiceImpl implements IFsUserAddressScrmService
         }
     }
 
+    @Override
+    public FsUserAddress selectFsUserAddressByDefault(long userId) {
+        return fsUserAddressMapper.selectFsUserAddressByDefault(userId);
+    }
+
     private String encrypt(String content, String keyValue, String charset) {
         if (keyValue != null) {
             content = content + keyValue;

+ 2 - 1
fs-service/src/main/java/com/fs/live/domain/LiveGoods.java

@@ -60,8 +60,9 @@ public class LiveGoods extends BaseEntity{
     private Long sort;
 
     /** 商品名称搜索关键字*/
-    
+
     private String keywords;
+    private String productName;
 
 
 }

+ 1 - 0
fs-service/src/main/java/com/fs/live/domain/LiveOrder.java

@@ -331,6 +331,7 @@ public class LiveOrder extends BaseEntity {
 
     private Long customerId;
     private Long couponUserId;
+    private Long recordId;
 
     /** 优惠券金额 */
     private BigDecimal couponPrice;

+ 7 - 0
fs-service/src/main/java/com/fs/live/domain/LiveUserLotteryRecord.java

@@ -35,5 +35,12 @@ public class LiveUserLotteryRecord extends BaseEntity{
     @Excel(name = "商品ID")
     private Long productId;
 
+    /** 商品ID */
+    @Excel(name = "订单ID")
+    private Long orderId;
+
+    @Excel(name = "订单状态")
+    /** 订单状态(-1 : 申请退款 -2 : 退货成功 0:已取消 1:待支付 2:待发货;3:待收货;4:待评价;5:已完成;-9 中奖未填写地址) */
+    private Integer orderStatus;
 
 }

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

@@ -39,8 +39,11 @@ public class LiveWatchUser extends BaseEntity {
     @Excel(name = "在线状态;0在线1离线")
     private Integer online = 0;
 
+    private Long onlineSeconds;
+
     /** 用户名字 */
 
     private String nickName;
+    private String tabName;
 
 }

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

@@ -13,6 +13,8 @@ public class LiveOrderItemDTO implements Serializable {
     private String sku;
 
     private String barCode;
+    private String groupBarCode;
+
 
     String productName;
 

+ 6 - 1
fs-service/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")
@@ -82,4 +82,9 @@ public interface LiveAutoTaskMapper {
 
     @Select("select * from live_auto_task where live_id= #{liveId} and task_type = 3")
     List<LiveAutoTask> selectLiveAutoTaskBarrageList(LiveAutoTask liveAutoTask);
+
+    void batchInsertLiveAutoTask(@Param("list") List<LiveAutoTask> addList);
+
+    void batchUpdateLiveAutoTask(@Param("list")  List<LiveAutoTask> updateList);
+
 }

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

@@ -69,11 +69,11 @@ public interface LiveCouponMapper
     @Select("select * from live_coupon where find_in_set(coupon_id,#{ids})")
     List<LiveCoupon> selectLiveCouponByIds(String ids);
 
-    @Select("select lc.*,lci.id,lcir.is_show,lcir.goods_id,fsp.product_name,fsp.images " +
+    @Select("select lc.*,lci.id,lcir.is_show,lcir.goods_id,fsp.product_name,fsp.image " +
             "from live_coupon_issue_relation lcir left join live_coupon_issue lci " +
             "left join live_coupon lc on lc.coupon_id=lci.coupon_id on lci.id = lcir.coupon_issue_id  " +
             "left join live_goods lg on lg.goods_id = lcir.goods_id " +
-            "left join fs_store_product fsp on lg.product_id = fsp.product_id " +
+            "left join fs_store_product_scrm fsp on lg.product_id = fsp.product_id " +
             "where lcir.live_id = #{liveId}")
     List<LiveCoupon> selectLiveCouponByLiveId(@Param("liveId") Long liveId);
 

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

@@ -105,7 +105,7 @@ public interface LiveLotteryConfMapper {
     @Select("select lulr.*,fu.nickname as user_name,fsp.product_name as product_name\n" +
             "        from live_user_lottery_record lulr left join fs_user fu on lulr.user_id = fu.user_id\n" +
             "        left join live_goods lg on lulr.product_id = lg.goods_id\n" +
-            "        left join fs_store_product fsp on lg.product_id = fsp.product_id\n" +
+            "        left join fs_store_product_scrm fsp on lg.product_id = fsp.product_id\n" +
             "        where lulr.user_id = #{userId}")
     List<LiveUserLotteryRecordVo> selectLiveUserLotteryRecordByUserId(long userId);
 }

+ 3 - 3
fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java

@@ -66,15 +66,15 @@ public interface LiveOrderItemMapper {
      */
     int deleteLiveOrderItemByItemIds(String[] itemIds);
 
-    @Select("select loi.*,fsp.bar_code from live_order_item loi left join fs_store_product fsp on loi.product_id =fsp.product_id   where loi.order_id = #{orderId}")
+    @Select("select loi.*,fsp.bar_code from live_order_item loi left join fs_store_product_scrm fsp on loi.product_id =fsp.product_id   where loi.order_id = #{orderId}")
     List<LiveOrderItem> selectLiveOrderItemByOrderId(Long orderId);
 
     @MapKey("orderId")
     @Select("<script>" +
             "select a.item_id, a.order_id as orderId, a.order_code, a.cart_id, a.goods_id, a.product_id, a.product_attr_value_id, a.json_info, a.num, a.is_after_sales, a.is_prescribe, a.store_id, a.is_gift\n" +
-            ", b.product_name, b.images as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce\n" +
+            ", b.product_name, b.image as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce\n" +
             "from live_order_item a\n" +
-            "left join fs_store_product b on a.product_id = b.product_id\n" +
+            "left join fs_store_product_scrm b on a.product_id = b.product_id\n" +
             "where order_id in\n" +
             "<foreach item='id' collection='orderIds' open='(' separator=',' close=')'> " +
             " #{id} " +

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

@@ -192,7 +192,7 @@ public interface LiveOrderMapper {
             "<if test=\"maps.status == 6\">" +
             "            AND o.`status` = 1" +
             "            AND (" +
-            "            o.store_id IN (SELECT store_id FROM fs_store WHERE delivery_type=2 OR delivery_type=1)" +
+            "            o.store_id IN (SELECT store_id FROM fs_store_scrm WHERE delivery_type=2 OR delivery_type=1)" +
             "            )" +
             "            AND (o.extend_order_id IS NULL OR o.extend_order_id = '')" +
             "        </if>" +

+ 12 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveUserLotteryRecordMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.fs.live.domain.LiveUserLotteryRecord;
 import com.fs.live.vo.LiveUserLotteryRecordVo;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
 /**
@@ -65,4 +66,15 @@ public interface LiveUserLotteryRecordMapper {
     boolean existsByUserIdAndRedId(Long lotteryId, String userId);
 
     List<LiveUserLotteryRecordVo> selectRecordByLiveIdAndLotteryId(LiveUserLotteryRecord liveUserLotteryRecord);
+
+    @Select("select lulr.*,fu.nickname as user_name,fsp.product_name as product_name\n" +
+            "        from live_user_lottery_record lulr left join fs_user fu on lulr.user_id = fu.user_id\n" +
+            "        " +
+            "        left join fs_store_product_scrm fsp on lulr.product_id = fsp.product_id\n" +
+            "        where lulr.user_id = #{userId} order by lulr.create_time desc")
+    List<LiveUserLotteryRecordVo> selectLiveUserLotteryRecordByUserId(@Param("userId") long userId);
+
+    @Select("update live_user_lottery_record set order_status = #{status} where order_id = #{orderId}")
+    void updateOrderStatusByOrderId(@Param("orderId") Long orderId,@Param("status") int status);
+
 }

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

@@ -2,6 +2,7 @@ package com.fs.live.mapper;
 
 
 import com.fs.live.domain.LiveWatchUser;
+import com.fs.live.vo.LiveWatchUserStatistics;
 import com.fs.live.vo.LiveWatchUserVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -97,9 +98,17 @@ public interface LiveWatchUserMapper {
 
     @Select("select a.*,fu.nickname as 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} ) 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);
+            "(SELECT FLOOR(RAND() * (SELECT MAX(registration_id) FROM live_lottery_registration)))) ) a left join fs_user fu on fu.user_id = a.user_id")
+    List<LiveWatchUser> selectLiveWatchAndRegisterUser(@Param("liveId") Long liveId,@Param("lotteryId") Long lotteryId);
 
     @Select("select * from live_watch_user where live_id = #{liveId} and user_id = #{userId}")
     LiveWatchUser selectUserByLiveIdAndUserId(@Param("liveId") long liveId,@Param("userId")  long userId);
+
+    @Select("SELECT " +
+            "    SUM(CASE WHEN online = 0 and msg_status = 0 THEN 1 ELSE 0 END) AS online, " +
+            "    SUM(CASE WHEN online = 1 and msg_status = 0 THEN 1 ELSE 0 END) AS offline, " +
+            "    SUM(CASE WHEN msg_status = 1 THEN 1 ELSE 0 END) AS silenced " +
+            "FROM " +
+            "    live_watch_user where live_id=#{liveId}")
+    LiveWatchUserStatistics liveUserTotals(LiveWatchUser liveWatchUser);
 }

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

@@ -83,4 +83,6 @@ public interface ILiveAutoTaskService {
     List<LiveAutoTask> selectLiveAutoTaskBarrageList(LiveAutoTask liveAutoTask);
 
     void directInsertLiveAutoTask(LiveAutoTask liveAutoTask);
+
+    void batchInsertLiveAutoTask(List<LiveAutoTask> addList);
 }

+ 6 - 0
fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java

@@ -206,6 +206,10 @@ public interface ILiveOrderService {
 
     void orderCancel();
 
+    LiveOrderComputeDTO computedReward(long l, LiveOrderComputedParam param);
+
+    R createRewardLiveOrder(LiveOrder liveOrder);
+
     boolean isEntityNull(LiveOrderParam param);
 
     List<LiveOrderVO> selectLiveOrderListVO(LiveOrderParam param);
@@ -225,4 +229,6 @@ public interface ILiveOrderService {
     List<FsMyLiveOrderListQueryVO> selectFsCompanyLiveOrderListVO(FsMyLiveOrderQueryParam param);
 
     Integer selectFsStoreOrderCount(long l, int i);
+
+    R payConfirmReward(LiveOrder liveOrder);
 }

+ 3 - 2
fs-service/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,8 @@ public interface ILiveWatchConfigService {
      * @param jsonConfig 直播观看奖励设置
      * @return 结果
      */
-    int updateLiveWatchConfig(String jsonConfig);
+    int updateLiveWatchConfig(String jsonConfig, Long liveId);
+
 
     /**
      * 批量删除直播观看奖励设置

+ 4 - 1
fs-service/src/main/java/com/fs/live/service/ILiveWatchUserService.java

@@ -1,6 +1,7 @@
 package com.fs.live.service;
 
 
+import com.fs.common.core.domain.R;
 import com.fs.live.domain.LiveWatchUser;
 import com.fs.live.vo.LiveWatchUserVO;
 
@@ -107,8 +108,10 @@ public interface ILiveWatchUserService {
     int blockUser(Long userId);
 
 
-    List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId,Integer totalLots);
+    List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId);
 
 
     List<LiveWatchUserVO> asyncToCache(Long liveId);
+
+    R liveUserTotals(LiveWatchUser liveWatchUser);
 }

+ 44 - 7
fs-service/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.live.service.impl;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
@@ -209,11 +210,35 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
     {
         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);
+        if (liveAutoTask.getTaskType() == 1L) {
+            // 商品
+            LiveGoodsVo liveGoodsVo = goodsService.selectLiveGoodsVoByGoodsId(Long.valueOf(liveAutoTask.getContent()));
+            if(liveGoodsVo == null) return -1;
+            liveAutoTask.setContent(JSON.toJSONString(liveGoodsVo));
+            return baseMapper.updateLiveAutoTask(liveAutoTask);
+        }else if (liveAutoTask.getTaskType() == 2L) {
+            // 红包
+            LiveRedConf liveRedConf = liveRedConfMapper.selectLiveRedConfByRedId(Long.valueOf(liveAutoTask.getContent()));
+            if(liveRedConf == null) return -1;
+            if(liveRedConf.getRedStatus() != 0L) return -1;
+            liveAutoTask.setContent(JSON.toJSONString(liveRedConf));
+            return baseMapper.updateLiveAutoTask(liveAutoTask);
+        }else if (liveAutoTask.getTaskType() == 4L) {
+            // 开启抽奖
+            LiveLotteryConf liveLotteryConf = liveLotteryConfMapper.selectLiveLotteryConfByLotteryId(Long.valueOf(liveAutoTask.getContent()));
+            if(liveLotteryConf == null) return -1;
+            if(!"0".equals(liveLotteryConf.getLotteryStatus())) return -1;
+            List<LiveLotteryProduct> prizes = lotteryProductConfMapper.selectLiveLotteryProductConfByLotteryId(liveLotteryConf.getLotteryId());
+            if (prizes == null || prizes.isEmpty()) {
+                return -1;
+            }
+            liveAutoTask.setContent(JSON.toJSONString(liveLotteryConf));
+            return baseMapper.updateLiveAutoTask(liveAutoTask);
+        } else if(liveAutoTask.getTaskType() == 3L){
+            return baseMapper.updateLiveAutoTask(liveAutoTask);
+        } else {
+            return -1;
+        }
     }
 
     /**
@@ -259,14 +284,21 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
     public void recalcLiveAutoTask(Live live) {
 
         if(live == null) return;
-        // 目前只重算 推送商品 弹幕脚本
         List<LiveAutoTask> liveAutoTasks = baseMapper.recalcLiveAutoTaskQuery(live.getLiveId());
         Date now = new Date();
+        List<LiveAutoTask> updateList = new ArrayList<>();
         for (LiveAutoTask liveAutoTask : liveAutoTasks) {
             liveAutoTask.setAbsValue(getTriggerValue(liveAutoTask.getTriggerValue(), live.getStartTime()));
             liveAutoTask.setUpdateTime(now);
             liveAutoTask.setFinishStatus(0L);
-            baseMapper.updateLiveAutoTask(liveAutoTask);
+            updateList.add(liveAutoTask);
+            if (updateList.size() >= 200) {
+                baseMapper.batchUpdateLiveAutoTask(updateList);
+                updateList.clear();
+            }
+        }
+        if (!updateList.isEmpty()) {
+            baseMapper.batchUpdateLiveAutoTask(updateList);
         }
     }
 
@@ -284,4 +316,9 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
     public void directInsertLiveAutoTask(LiveAutoTask liveAutoTask) {
         baseMapper.insertLiveAutoTask(liveAutoTask);
     }
+
+    @Override
+    public void batchInsertLiveAutoTask(List<LiveAutoTask> addList) {
+        baseMapper.batchInsertLiveAutoTask(addList);
+    }
 }

+ 7 - 5
fs-service/src/main/java/com/fs/live/service/impl/LiveGoodsServiceImpl.java

@@ -7,6 +7,8 @@ import com.fs.common.utils.DateUtils;
 import com.fs.company.domain.CompanyUser;
 import com.fs.his.domain.FsStoreProduct;
 import com.fs.his.mapper.FsStoreProductMapper;
+import com.fs.hisStore.domain.FsStoreProductScrm;
+import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
 import com.fs.live.domain.LiveGoods;
 import com.fs.live.mapper.LiveGoodsMapper;
 import com.fs.live.service.ILiveGoodsService;
@@ -31,7 +33,7 @@ import java.util.stream.Collectors;
 public class LiveGoodsServiceImpl  implements ILiveGoodsService {
 
     @Autowired
-    private FsStoreProductMapper fsStoreProductMapper;
+    private FsStoreProductScrmMapper fsStoreProductMapper;
 
     @Autowired
     private LiveGoodsMapper baseMapper;
@@ -87,7 +89,7 @@ public class LiveGoodsServiceImpl  implements ILiveGoodsService {
         LiveGoods existGoods = baseMapper.selectLiveGoodsByGoodsId(liveGoods.getGoodsId());
         if (liveGoods.getStock() != null) {
             if(liveGoods.getProductId() == null) return R.error("店铺已停止售卖商品!");
-            FsStoreProduct fsStoreProduct = fsStoreProductMapper.selectFsStoreProductById(liveGoods.getProductId());
+            FsStoreProductScrm fsStoreProduct = fsStoreProductMapper.selectFsStoreProductById(liveGoods.getProductId());
             if(fsStoreProduct == null) return R.error("商品不存在");
             if(fsStoreProduct.getIsShow() == 0 || existGoods.getStatus() == 0) return R.error("商品已下架");
             if(fsStoreProduct.getStock() < liveGoods.getStock()) return R.error("商品库存不足");
@@ -194,7 +196,7 @@ public class LiveGoodsServiceImpl  implements ILiveGoodsService {
         }
         List<Long> productIdsLong = productIdList.stream().map(Long::parseLong).collect(Collectors.toList());
         //  查询商品信息列表(假设返回 List<StoreProduct>)
-        List<FsStoreProduct> productInfoList = fsStoreProductMapper.getStoreProductInProductIds(productIdsLong);
+        List<FsStoreProductScrm> productInfoList = fsStoreProductMapper.selectFsStoreProductByProductIds(productIdsLong);
 
         //  转换为 LiveGoods 并批量插入
         List<LiveGoods> liveGoodsList = productInfoList.stream()
@@ -207,7 +209,7 @@ public class LiveGoodsServiceImpl  implements ILiveGoodsService {
                     liveGoods.setStatus(1);
                     liveGoods.setIsShow(false);
                     liveGoods.setSales(Math.toIntExact(product.getSales()));
-                    liveGoods.setStock(Long.valueOf(product.getStock()));
+                    liveGoods.setStock(product.getStock());
                     liveGoods.setSort(product.getSort());
                     liveGoods.setCreateTime(DateUtils.getNowDate());
                     liveGoods.setCreateBy(String.valueOf(user.getUserId()));
@@ -236,7 +238,7 @@ public class LiveGoodsServiceImpl  implements ILiveGoodsService {
         }
         List<Long> productIdsLong = productIdList.stream().map(Long::parseLong).collect(Collectors.toList());
         //  查询商品信息列表(假设返回 List<StoreProduct>)
-        List<FsStoreProduct> productInfoList = fsStoreProductMapper.getStoreProductInProductIds(productIdsLong);
+        List<FsStoreProductScrm> productInfoList = fsStoreProductMapper.selectFsStoreProductByProductIds(productIdsLong);
 
         //  转换为 LiveGoods 并批量插入
         List<LiveGoods> liveGoodsList = productInfoList.stream()

+ 285 - 75
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -41,6 +41,7 @@ import com.fs.company.mapper.CompanyMoneyLogsMapper;
 import com.fs.company.service.ICompanyDeptService;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
+import com.fs.core.utils.OrderCodeUtils;
 import com.fs.erp.domain.*;
 import com.fs.erp.dto.*;
 import com.fs.erp.mapper.FsErpFinishPushMapper;
@@ -65,10 +66,12 @@ import com.fs.hisStore.enums.OrderInfoEnum;
 import com.fs.hisStore.enums.OrderLogEnum;
 import com.fs.hisStore.enums.ShipperCodeEnum;
 import com.fs.hisStore.enums.SysConfigEnum;
+import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
 import com.fs.hisStore.param.FsStoreOrderAddTuiMoneyParam;
 import com.fs.hisStore.param.FsStoreOrderParam;
 import com.fs.hisStore.param.FsStoreOrderScrmSetErpPhoneParam;
 import com.fs.hisStore.service.IFsExpressScrmService;
+import com.fs.hisStore.service.IFsStoreProductScrmService;
 import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
@@ -127,7 +130,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     private LiveOrderItemMapper liveOrderItemMapper;
 
     @Autowired
-    private IFsStoreProductService fsStoreProductService;
+    private IFsStoreProductScrmService fsStoreProductService;
 
     @Autowired
     FsUserMapper userMapper;
@@ -141,7 +144,10 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     private ICompanyService companyService;
 
     @Autowired
-    private FsStoreProductAttrValueMapper fsStoreProductAttrValueMapper;
+    private FsStoreProductAttrValueScrmMapper fsStoreProductAttrValueMapper;
+
+    @Autowired
+    private LiveUserLotteryRecordMapper liveUserLotteryRecordMapper;
 
     @Autowired
     ICompanyUserService companyUserService;
@@ -197,6 +203,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
 
 
+
     @Autowired
     private LiveOrderPaymentErrorMapper liveOrderPaymentErrorMapper;
 
@@ -761,60 +768,41 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
     @Override
     public List<LiveOrderListVo> selectLiveOrderListVo(LiveOrder liveOrder) {
-//        List<LiveOrderListVo> liveOrders = baseMapper.selectLiveOrderListVo(liveOrder.getUserId(),liveOrder.getStatus());
-//        List<Long> allOrderIds = liveOrders.stream().map(LiveOrderListVo::getOrderId)
-//                .filter(Objects::nonNull).collect(Collectors.toList());
-//
-//        if(CollectionUtils.isEmpty(allOrderIds)) {
-//            return Collections.emptyList();
-//        }
-//
-//        Map<Long, FsStoreDelivers> byOrderIdWithTypeBatch = fsStoreDeliversMapper
-//                .findByOrderIdWithTypeBatch(allOrderIds, 1);
-//
-//        Map<Long,LiveAfterSales> liveAfterSalesMap = liveAfterSalesMapper.findByOrderIds(allOrderIds);
-//
-//        List<LiveOrderItemVo> liveOrderItemVosList = liveOrderItemMapper.selectLiveOrderItemByOrderIds(allOrderIds);
-//        Map<Long, List<LiveOrderItemVo>> orderItemsMap = liveOrderItemVosList.stream()
-//                .collect(Collectors.groupingBy(
-//                        LiveOrderItemVo::getOrderId,
-//                        LinkedHashMap::new,
-//                        Collectors.toList()
-//                ));
-//
-//        for (LiveOrderListVo order : liveOrders) {
-//            FsStoreDelivers delivers = byOrderIdWithTypeBatch.get(order.getOrderId());
-//
-//            if(ObjectUtil.isNotNull(delivers)) {
-//                order.setDeliveryCode(delivers.getDeliverSn());
-//                order.setDeliveryName(delivers.getDeliverName());
-//                order.setDeliverySn(delivers.getDeliverId());
-//                order.setDeliveryStatus(delivers.getStatus());
-//                order.setDeliveryType(String.valueOf(delivers.getStateEx()));
-//            }else {
-//                order.setDeliveryCode(null);
-//                order.setDeliveryName(null);
-//                order.setDeliverySn(null);
-//                order.setDeliveryStatus(null);
-//                order.setDeliveryType(null);
-//            }
-//            if(ObjectUtil.isNotNull(liveAfterSalesMap)){
-//                LiveAfterSales liveAfterSales = liveAfterSalesMap.get(order.getOrderId());
-//                if(ObjectUtil.isNotNull(liveAfterSales)) {
-//                    order.setAfterSaleId(liveAfterSales.getId());
-//                }
-//            }
-//
-//            if(ObjectUtil.isNotNull(orderItemsMap)){
-//                Long orderId = order.getOrderId();
-//                List<LiveOrderItemVo> liveOrderItemVos = orderItemsMap.get(orderId);
-//                if(CollectionUtils.isNotEmpty(liveOrderItemVos)) {
-//                    order.setOrderItemList(liveOrderItemVos);
-//                }
-//            }
-//        }
-//        return liveOrders;
-        return null;
+        List<LiveOrderListVo> liveOrders = baseMapper.selectLiveOrderListVo(liveOrder.getUserId(),liveOrder.getStatus());
+        List<Long> allOrderIds = liveOrders.stream().map(LiveOrderListVo::getOrderId)
+                .filter(Objects::nonNull).collect(Collectors.toList());
+
+        if(CollectionUtils.isEmpty(allOrderIds)) {
+            return Collections.emptyList();
+        }
+
+        Map<Long,LiveAfterSales> liveAfterSalesMap = liveAfterSalesMapper.findByOrderIds(allOrderIds);
+
+        List<LiveOrderItemVo> liveOrderItemVosList = liveOrderItemMapper.selectLiveOrderItemByOrderIds(allOrderIds);
+        Map<Long, List<LiveOrderItemVo>> orderItemsMap = liveOrderItemVosList.stream()
+                .collect(Collectors.groupingBy(
+                        LiveOrderItemVo::getOrderId,
+                        LinkedHashMap::new,
+                        Collectors.toList()
+                ));
+
+        for (LiveOrderListVo order : liveOrders) {
+            if(ObjectUtil.isNotNull(liveAfterSalesMap)){
+                LiveAfterSales liveAfterSales = liveAfterSalesMap.get(order.getOrderId());
+                if(ObjectUtil.isNotNull(liveAfterSales)) {
+                    order.setAfterSaleId(liveAfterSales.getId());
+                }
+            }
+
+            if(ObjectUtil.isNotNull(orderItemsMap)){
+                Long orderId = order.getOrderId();
+                List<LiveOrderItemVo> liveOrderItemVos = orderItemsMap.get(orderId);
+                if(CollectionUtils.isNotEmpty(liveOrderItemVos)) {
+                    order.setOrderItemList(liveOrderItemVos);
+                }
+            }
+        }
+        return liveOrders;
     }
 
     @Override
@@ -1014,6 +1002,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 //        order.setStatus(-2);
 //        order.setRefundMoney(order.getPayMoney());
 //        order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_2.getValue()));
+//        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), -2);
+
 //        baseMapper.updateLiveOrder(order);
 //
 //        //退库存
@@ -1070,6 +1060,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 //        order.setStatus(-2);
 //        order.setRefundMoney(order.getPayMoney());
 //        order.setRefundStatus(String.valueOf(OrderInfoEnum.REFUND_STATUS_2.getValue()));
+//        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), -2);
+
 //        baseMapper.updateLiveOrder(order);
 //
 //        //退库存
@@ -1374,7 +1366,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 //            order.setDeliveryName(deliverName);
 //            order.setDeliverySn(deliveryId);
 //            order.setDeliveryCode(express.getCode());
-//
+//            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), 3);
 //            baseMapper.updateLiveOrder(order);
 //            if(ObjectUtil.isNotNull(express)) {
 //                FsStoreDelivers fsStoreDeliver = new FsStoreDelivers();
@@ -1428,6 +1420,140 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         return;
     }
 
+    @Override
+    public LiveOrderComputeDTO computedReward(long l, LiveOrderComputedParam param) {
+        String orderKey= redisCache.getCacheObject("orderKey:"+param.getOrderKey());
+        if (StringUtils.isEmpty(orderKey)) {
+            return null;
+        }
+        FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
+        if(fsStoreProduct == null) return null;
+        BigDecimal payPrice = BigDecimal.ZERO;
+        BigDecimal payDelivery = BigDecimal.ZERO;
+        BigDecimal totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
+        if (param.getCityId() != null) {
+            payDelivery = handleDeliveryMoney(param.getCityId(), fsStoreProduct, param.getTotalNum());
+            totalPrice = totalPrice.add(payDelivery);
+        }
+        return LiveOrderComputeDTO.builder().payPrice(payPrice)
+                .payDelivery(payDelivery)
+                .deductionPrice(totalPrice)
+                .totalPrice(totalPrice)
+                .build();
+    }
+
+    @Override
+    public R createRewardLiveOrder(LiveOrder liveOrder) {
+        String orderKey= redisCache.getCacheObject("orderKey:"+liveOrder.getOrderKey());
+        if (StringUtils.isEmpty(orderKey)) {
+            return R.error("订单已过期");
+        }
+        LiveUserLotteryRecord liveUserLotteryRecord = liveUserLotteryRecordMapper.selectLiveUserLotteryRecordById(liveOrder.getRecordId());
+        if(liveUserLotteryRecord == null) return R.error("未查询到中奖记录,请联系管理员处理!");
+        if(liveOrder.getLiveId() == null) return R.error("直播ID不能为空");
+        if(liveOrder.getProductId() == null) return R.error("购物商品ID不能为空");
+        if(liveOrder.getUserName() == null) return R.error("用户名不能为空");
+        if(liveOrder.getUserPhone() == null) return R.error("用户手机号不能为空");
+        if(liveOrder.getUserAddress() == null) return R.error("用户地址不能为空");
+        if(liveOrder.getTotalNum() == null) return R.error("商品数量不能为空");
+
+        Live live = liveMapper.selectLiveByLiveId(liveOrder.getLiveId());
+        if(live == null) return R.error("当前直播不存在");
+        FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(liveOrder.getProductId());
+        LiveGoods goods = liveGoodsMapper.selectLiveGoodsByProductId(liveOrder.getLiveId(), liveOrder.getProductId());
+        if(goods == null) return R.error("当前商品不存在");
+
+        // 更改店铺库存
+        fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
+        fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
+        // 更新直播间库存
+        goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
+        liveGoodsMapper.updateLiveGoods(goods);
+
+        //判断是否是三种特定产品
+        if (fsStoreProduct.getProductId() != null && (fsStoreProduct.getProductId().equals(3168L)
+                || fsStoreProduct.getProductId().equals(3184L)
+                || fsStoreProduct.getProductId().equals(3185L))) {
+            liveOrder.setStoreHouseCode("YDSP001");
+        } else {
+            liveOrder.setStoreHouseCode("CQDS001");
+        }
+
+        LiveUserFirstEntry liveUserFirstEntry = liveUserFirstEntryService.selectEntityByLiveIdUserId(liveOrder.getLiveId(), Long.parseLong(liveOrder.getUserId()));
+        liveOrder.setCompanyId(liveUserFirstEntry.getCompanyId());
+        liveOrder.setCompanyUserId(liveUserFirstEntry.getCompanyUserId());
+        liveOrder.setTuiUserId(liveUserFirstEntry.getCompanyUserId());
+
+        String orderSn = OrderCodeUtils.getOrderSn();
+        log.info("订单生成:"+orderSn);
+        liveOrder.setOrderCode(orderSn);
+        BigDecimal totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
+        // 直播不需要服务费 0915 1735 左
+//        String config=configService.selectConfigByKey("store.config");
+//        StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
+//        BigDecimal serviceFee=new BigDecimal(0);
+//        if(storeConfig.getServiceFee()!=null){
+//            if(liveOrder.getCompanyUserId()==null||liveOrder.getCompanyUserId()==0){
+//                serviceFee=storeConfig.getServiceFee();
+//            }
+//        }
+//        payPrice = payPrice.add(serviceFee);
+        // 生成
+        BigDecimal deliveryMoney = handleDeliveryMoney(liveOrder);
+        totalPrice = totalPrice.add(deliveryMoney);
+        liveOrder.setDiscountMoney(totalPrice);
+
+
+        liveOrder.setItemJson(JSON.toJSONString(fsStoreProduct));
+        liveOrder.setCreateTime(new Date());
+        liveOrder.setUpdateTime(new Date());
+        liveOrder.setPayDelivery(deliveryMoney);
+        liveOrder.setProductId(fsStoreProduct.getProductId());
+        liveOrder.setStatus(OrderInfoEnum.STATUS_1.getValue());
+        liveOrder.setPayType("1");
+        liveOrder.setTotalPrice(totalPrice);
+        liveOrder.setPayMoney(BigDecimal.ZERO);
+        try {
+            if (baseMapper.insertLiveOrder(liveOrder) > 0) {
+                liveUserLotteryRecord.setOrderId(liveOrder.getOrderId());
+                liveUserLotteryRecord.setOrderStatus(liveOrder.getStatus());
+                liveUserLotteryRecordMapper.updateLiveUserLotteryRecord(liveUserLotteryRecord);
+                LiveOrderItemDTO dto=new LiveOrderItemDTO();
+                dto.setImage(fsStoreProduct.getImgUrl());
+                dto.setSku(String.valueOf(fsStoreProduct.getStock()));
+                if (StringUtils.isEmpty(fsStoreProduct.getBarCode())) {
+                    FsStoreProductAttrValueScrm fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attrValue -> StringUtils.isNotEmpty(attrValue.getBarCode())).findFirst().orElse(null);
+                    if (fsStoreProductAttrValue != null) {
+                        dto.setBarCode(fsStoreProductAttrValue.getBarCode());
+                    }
+                } else {
+                    dto.setBarCode(fsStoreProduct.getBarCode());
+                }
+                dto.setPrice(fsStoreProduct.getPrice());
+                dto.setProductName(fsStoreProduct.getProductName());
+                dto.setNum(Long.valueOf(liveOrder.getTotalNum()));
+
+                LiveOrderItem liveOrderItem = new LiveOrderItem();
+                liveOrderItem.setOrderCode(liveOrder.getOrderCode());
+                liveOrderItem.setOrderId(liveOrder.getOrderId());
+                liveOrderItem.setProductId(liveOrder.getProductId());
+                liveOrderItem.setNum(Long.valueOf(liveOrder.getTotalNum()));
+                liveOrderItem.setJsonInfo(JSON.toJSONString(dto));
+                liveOrderItemMapper.insertLiveOrderItem(liveOrderItem);
+                redisCache.deleteObject("orderKey:" + liveOrder.getOrderKey());
+                return R.ok("下单成功").put("order",liveOrder);
+            } else {
+                return R.error("订单创建失败");
+            }
+        } catch (Exception e) {
+            // 异常处理
+            return R.error("订单创建失败:" + e.getMessage());
+        }
+    }
+
+
+
+
 
     @Override
     public LiveOrderComputeDTO computedOrder(long userId, LiveOrderComputedParam param) {
@@ -1435,7 +1561,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if (StringUtils.isEmpty(orderKey)) {
             return null;
         }
-        FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
+        FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(param.getProductId());
         BigDecimal totalPrice = BigDecimal.ZERO;
         BigDecimal payPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(param.getTotalNum()));
         totalPrice = totalPrice.add(payPrice);
@@ -1449,7 +1575,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if(param.getCouponUserId()!=null){
             LiveCouponUser couponUser=liveCouponUserService.selectLiveCouponUserById(param.getCouponUserId());
             if(couponUser!=null&&couponUser.getStatus()==0){
-                if(couponUser.getUseMinPrice().compareTo(payPrice)==-1){
+                if(couponUser.getUseMinPrice().compareTo(payPrice)< 1){
                     payPrice=payPrice.subtract(couponUser.getCouponPrice());
                     deductionPrice = couponUser.getCouponPrice();
                 }
@@ -1537,6 +1663,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 //                            map.setStatus(OrderInfoEnum.STATUS_2.getValue());
 //                            map.setOrderId(order.getOrderId());
 //                            map.setDeliverySn(response.getOrders().get(0).getDeliverys().get(0).getMail_no());
+//        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), 2);
+
 //                            liveOrderMapper.updateLiveOrder(map);
 //                            liveOrderLogsService.create(order.getOrderId(), OrderLogEnum.DELIVERY_GOODS.getValue(),
 //                                    OrderLogEnum.DELIVERY_GOODS.getDesc());
@@ -1882,7 +2010,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         return liveOrderMapper.selectLiveOrderCount(userId, status);
     }
 
-    private BigDecimal handleDeliveryMoney(Long cityId, FsStoreProduct fsStoreProduct, String totalNumSize) {
+    private BigDecimal handleDeliveryMoney(Long cityId, FsStoreProductScrm fsStoreProduct, String totalNumSize) {
         BigDecimal storePostage = BigDecimal.ZERO;
 //        List<Long> citys = new ArrayList<>();
 //        citys.add(cityId);
@@ -1982,6 +2110,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if(order.getStatus()==OrderInfoEnum.STATUS_3.getValue()){
             order.setFinishTime(new Date());
             order.setStatus(4);
+            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), 4);
             baseMapper.updateLiveOrder(order);
             liveOrderLogsService.create(order.getOrderId(), OrderLogEnum.FINISH_ORDER.getValue(),
                     OrderLogEnum.FINISH_ORDER.getDesc());
@@ -2042,6 +2171,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     public int updateLiveOrder(LiveOrder liveOrder)
     {
         liveOrder.setUpdateTime(DateUtils.getNowDate());
+        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(liveOrder.getOrderId(), liveOrder.getStatus());
         return baseMapper.updateLiveOrder(liveOrder);
     }
 
@@ -2199,6 +2329,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 //                OrderLogEnum.FINISH_ORDER.getDesc());
 
         int i = baseMapper.updateLiveOrder(updateEntity);
+        liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), OrderInfoEnum.STATUS_3.getValue());
 
         return i;
     }
@@ -2265,6 +2396,84 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         return null;
 
     }
+    @Override
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    public R payConfirmReward(LiveOrder liveOrder) {
+        Long orderId = liveOrder.getOrderId();
+        if(orderId==null) return R.error("订单ID不存在");
+        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+        try {
+            liveOrder = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
+            if(liveOrder==null || !liveOrder.getStatus().equals(1)){
+                throw new CustomException("当前订单未找到或者订单状态不为待支付! orderId:" + orderId);
+            }
+            FsUser user = userMapper.selectFsUserByUserId(Long.valueOf(liveOrder.getUserId()));
+            if(user == null) return R.error("用户不存在");
+            String json = configService.selectConfigByKey("store.pay");
+            FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
+            String payCode =  OrderCodeUtils.getOrderSn();
+            if(StringUtils.isEmpty(payCode)){
+                return R.error("订单生成失败,请重试");
+            }
+            LiveOrderPayment storePayment = liveOrderPaymentMapper.selectByBuissnessId(liveOrder.getOrderId());
+            if (storePayment != null) {
+                storePayment.setStatus(1);
+                liveOrderPaymentMapper.updateLiveOrderPayment(storePayment);
+            } else {
+                storePayment = new LiveOrderPayment();
+                storePayment.setStatus(1);
+                storePayment.setPayMode(fsPayConfig.getType());
+                storePayment.setBusinessCode(liveOrder.getOrderCode());
+                storePayment.setPayCode(payCode);
+                storePayment.setPayMoney(liveOrder.getPayMoney());
+//                storePayment.setPayMoney(new BigDecimal("0.01"));
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("weixin");
+                storePayment.setBusinessType(5);
+                storePayment.setRemark("直播商品订单支付");
+                storePayment.setOpenId(user.getMaOpenId());
+                storePayment.setUserId(user.getUserId());
+                storePayment.setBusinessId(liveOrder.getOrderId().toString());
+                liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
+            }
+
+            if (storePayment!=null){
+                if(storePayment.getStatus().equals(0)){
+                    LiveOrderPayment paymentMap=new LiveOrderPayment();
+                    paymentMap.setPaymentId(storePayment.getPaymentId());
+                    paymentMap.setStatus(1);
+                    paymentMap.setPayTime(new Date());
+                    liveOrderPaymentMapper.updateLiveOrderPayment(paymentMap);
+                }
+            }
+            else{
+                log.info("支付单号不存在:"+payCode);
+                throw new CustomException("当前支付记录未找到!");
+            }
+            if(liveOrder.getStatus()!=1){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return R.error("当前订单未找到或者订单状态不为待支付!");
+            }
+            //增加用户购买次数
+            userMapper.incPayCount(Long.valueOf(liveOrder.getUserId()));
+
+            liveOrder.setStatus(2);
+            liveOrder.setPayTime(LocalDateTime.now());
+            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(liveOrder.getOrderId(), 2);
+            baseMapper.updateLiveOrder(liveOrder);
+            return R.ok("支付成功");
+        }catch (Exception e){
+            log.info("抽奖订单支付错误:"+e.getMessage());
+            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+            LiveOrderPaymentError err = new LiveOrderPaymentError();
+            err.setOrderNo(String.valueOf(orderId));
+            err.setStatus(0);
+            err.setMsg("抽奖订单支付错误:"+e.getMessage());
+            err.setCreateTime(DateUtils.getNowDate());
+            liveOrderPaymentErrorMapper.insertLiveOrderPaymentError(err);
+            return R.error("支付失败");
+        }
+    }
 
 
     @Override
@@ -2287,8 +2496,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
 
         Live live = liveMapper.selectLiveByLiveId(liveOrder.getLiveId());
         if(live == null) return R.error("当前直播不存在");
-        FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(liveOrder.getProductId());
+        FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(liveOrder.getProductId());
         LiveGoods goods = liveGoodsMapper.selectLiveGoodsByProductId(liveOrder.getLiveId(), liveOrder.getProductId());
+        if(goods == null) 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("抱歉,这款商品已被抢光,暂时无库存~");
@@ -2339,12 +2549,14 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 if (!couponUser.getUserId().toString().equals(liveOrder.getUserId())){
                     return R.error("非法操作");
                 }
-                liveOrder.setUserCouponId(couponUser.getId());
-                liveOrder.setDiscountMoney(couponUser.getCouponPrice());
-                //更新优惠券状态
-                couponUser.setStatus(1);
-                couponUser.setUseTime(new Date());
-                liveCouponUserService.updateLiveCouponUser(couponUser);
+                if(couponUser.getUseMinPrice().compareTo(payPrice) < 1){
+                    liveOrder.setUserCouponId(couponUser.getId());
+                    liveOrder.setDiscountMoney(couponUser.getCouponPrice());
+                    //更新优惠券状态
+                    couponUser.setStatus(1);
+                    couponUser.setUseTime(new Date());
+                    liveCouponUserService.updateLiveCouponUser(couponUser);
+                }
             }
         }
 
@@ -2362,13 +2574,10 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 LiveOrderItemDTO dto=new LiveOrderItemDTO();
                 dto.setImage(fsStoreProduct.getImgUrl());
                 dto.setSku(String.valueOf(fsStoreProduct.getStock()));
-                if (StringUtils.isEmpty(fsStoreProduct.getBarCode())) {
-                    FsStoreProductAttrValue fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attrValue -> StringUtils.isNotEmpty(attrValue.getBarCode())).findFirst().orElse(null);
-                    if (fsStoreProductAttrValue != null) {
-                        dto.setBarCode(fsStoreProductAttrValue.getBarCode());
-                    }
-                } else {
-                    dto.setBarCode(fsStoreProduct.getBarCode());
+                FsStoreProductAttrValueScrm fsStoreProductAttrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(fsStoreProduct.getProductId()).stream().filter(attrValue -> StringUtils.isNotEmpty(attrValue.getBarCode())).findFirst().orElse(null);
+                if (fsStoreProductAttrValue != null) {
+                    dto.setBarCode(fsStoreProductAttrValue.getBarCode());
+                    dto.setGroupBarCode(fsStoreProductAttrValue.getGroupBarCode());
                 }
                 dto.setPrice(fsStoreProduct.getPrice());
                 dto.setProductName(fsStoreProduct.getProductName());
@@ -2504,11 +2713,12 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         if(order.getStatus() == 1){
             LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(String.valueOf(order.getOrderId()));
             if(liveOrder == null) return R.error("订单不存在");
+            liveUserLotteryRecordMapper.updateOrderStatusByOrderId(order.getOrderId(), -3);
             baseMapper.cancelOrder(order.getOrderId());
             liveOrderLogsService.create(order.getOrderId(), OrderLogEnum.CANCEL_ORDER.getValue(),
                     OrderLogEnum.CANCEL_ORDER.getDesc());
             // 恢复库存
-            FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(liveOrder.getProductId());
+            FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(liveOrder.getProductId());
             LiveGoods goods = liveGoodsMapper.selectLiveGoodsByProductId(liveOrder.getLiveId(), liveOrder.getProductId());
             fsStoreProduct.setStock(fsStoreProduct.getStock()+Integer.parseInt(liveOrder.getTotalNum()));
             fsStoreProductService.updateFsStoreProduct(fsStoreProduct);

+ 78 - 63
fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -6,8 +6,11 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 
 import com.fs.common.exception.base.BaseException;
+import com.fs.his.domain.FsStoreProduct;
 import com.fs.his.domain.FsUser;
 import com.fs.his.mapper.FsUserMapper;
+import com.fs.hisStore.domain.FsStoreProductScrm;
+import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
 import com.fs.live.dto.TemplateMessageSendRequestDTO;
 import com.fs.live.enums.MiniAppNotifyTaskStatusEnum;
 import com.fs.live.vo.LiveVo;
@@ -81,6 +84,8 @@ public class LiveServiceImpl implements ILiveService
     @Autowired
     private LiveLotteryProductConfMapper liveLotteryProductConfMapper;
     @Autowired
+    private FsStoreProductScrmMapper fsStoreProductScrmMapper;
+    @Autowired
     private RedisCache redisCache;
     @Autowired
     private LiveMapper baseMapper;
@@ -381,6 +386,7 @@ public class LiveServiceImpl implements ILiveService
         }
         int result = baseMapper.updateLive(live);
         liveAutoTaskService.recalcLiveAutoTask(live);
+
         return result;
     }
 
@@ -646,6 +652,13 @@ public class LiveServiceImpl implements ILiveService
         exist.setFinishTime( null);
         exist.setStartTime(LocalDateTime.now());
         baseMapper.updateLive(exist);
+        List<LiveAutoTask> liveAutoTasks = liveAutoTaskService.selectNoActivedByLiveId(exist.getLiveId(), new Date());
+        liveAutoTasks.forEach(liveAutoTask -> {
+            liveAutoTask.setCreateTime(null);
+            liveAutoTask.setUpdateTime(null);
+            redisCache.redisTemplate.opsForZSet().add("live:auto_task:" + live.getLiveId(), JSON.toJSONString(liveAutoTask),liveAutoTask.getAbsValue().getTime());
+            redisCache.redisTemplate.expire("live:auto_task:"+live.getLiveId(), 1, TimeUnit.DAYS);
+        });
 
 
         return R.ok();
@@ -718,42 +731,36 @@ 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());
+        List<LiveAutoTask> addList = new ArrayList<>();
         if (!barrageTask.isEmpty()) {
-            LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
             for (LiveAutoTask liveAutoTask : barrageTask) {
+                LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
                 BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
                 liveAutoTaskEntity.setId(null);
                 liveAutoTaskEntity.setLiveId(newLiveId);
                 liveAutoTaskEntity.setCreateTime(now);
                 liveAutoTaskEntity.setUpdateTime(now);
                 liveAutoTaskEntity.setFinishStatus(0L);
-                liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity,liveEntity);
+                addList.add(liveAutoTaskEntity);
+                if (addList.size() > 100) {
+                    liveAutoTaskService.batchInsertLiveAutoTask(addList);
+                    addList.clear();
+                }
             }
         }
+        if (!addList.isEmpty()) {
+            liveAutoTaskService.batchInsertLiveAutoTask(addList);
+            addList.clear();
+        }
         //直播间红包配置
         List<LiveRedConf> liveRedConfs = liveRedConfService.selectByLiveId(existLiveId);
         if (!liveRedConfs.isEmpty()) {
-            LiveRedConf liveRedConfEntity = new LiveRedConf();
+
             for (LiveRedConf liveRedConf : liveRedConfs) {
+                LiveRedConf liveRedConfEntity = new LiveRedConf();
                 BeanUtils.copyBeanProp(liveRedConfEntity, liveRedConf);
                 liveRedConfEntity.setRedId(null);
                 liveRedConfEntity.setLiveId(newLiveId);
@@ -761,27 +768,27 @@ 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);
             }
         }
         // 直播间礼物配置
         List<LiveLotteryConf> liveLotteryConfs = liveLotteryConfService.selectByLiveId(existLiveId);
         if (!liveLotteryConfs.isEmpty()) {
-            LiveLotteryConf liveLotteryConfEntity = new LiveLotteryConf();
+
             List<Long> lotteryIds = liveLotteryConfs.stream().map(LiveLotteryConf::getLotteryId).collect(Collectors.toList());
             List<LiveLotteryProductConf> products = liveLotteryProductConfMapper.selectEntityByIds(lotteryIds);
             for (LiveLotteryConf liveLotteryConf : liveLotteryConfs) {
+                LiveLotteryConf liveLotteryConfEntity = new LiveLotteryConf();
                 BeanUtils.copyBeanProp(liveLotteryConfEntity, liveLotteryConf);
                 liveLotteryConfEntity.setLotteryId(null);
                 liveLotteryConfEntity.setLiveId(newLiveId);
@@ -794,48 +801,56 @@ 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);
             }
         }
+        LiveGoods queryParam = new LiveGoods();
+        queryParam.setLiveId(existLiveId);
         // 直播间商品
-        List<LiveGoods> goodsList = liveGoodsService.selectByLiveId(existLiveId);
+        List<LiveGoodsVo> goodsList = liveGoodsService.selectProductListByLiveId(queryParam);
         if (!goodsList.isEmpty()) {
-            LiveGoods liveGoodsEntity = new LiveGoods();
-            for (LiveGoods liveGoods : goodsList) {
+
+            List<Long> goodsProductIds = goodsList.stream().map(item -> item.getProductId()).collect(Collectors.toList());
+            Map<Long, FsStoreProductScrm> goodsMap = fsStoreProductScrmMapper.selectFsStoreProductByProductIds(goodsProductIds).stream().collect(Collectors.toMap(FsStoreProductScrm::getProductId, item -> item));
+
+            for (LiveGoodsVo liveGoods : goodsList) {
+                LiveGoods liveGoodsEntity = new LiveGoods();
                 BeanUtils.copyBeanProp(liveGoodsEntity, liveGoods);
                 liveGoodsEntity.setGoodsId(null);
                 liveGoodsEntity.setLiveId(newLiveId);
                 liveGoodsEntity.setCreateTime(now);
+                liveGoodsEntity.setIsShow(false);
                 liveGoodsEntity.setCompanyId(live.getCompanyId());
                 liveGoodsEntity.setCompanyUserId(live.getCompanyUserId());
                 liveGoodsService.insertLiveGoods(liveGoodsEntity);
+                // 优惠券
                 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;
+                liveGoods.setGoodsId(liveGoodsEntity.getGoodsId());
+                LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
+                BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
+                liveAutoTaskEntity.setId(null);
+                liveAutoTaskEntity.setLiveId(newLiveId);
+                liveGoodsEntity.setStock(goodsMap.containsKey(liveGoods.getProductId()) ? goodsMap.get(liveGoods.getProductId()).getStock() : 0);
+                liveAutoTaskEntity.setCreateTime(now);
+                liveAutoTaskEntity.setUpdateTime(now);
+                liveAutoTaskEntity.setFinishStatus(0L);
+                liveAutoTaskEntity.setContent(JSON.toJSONString(liveGoods));
+                liveAutoTaskService.directInsertLiveAutoTask(liveAutoTaskEntity);
+
             }
         }
         for (LiveCouponIssueRelation liveCouponIssueRelation : liveCouponIssueRelations) {

+ 10 - 9
fs-service/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);
     }
 
     /**

+ 43 - 2
fs-service/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.thread.ThreadUtil;
 import com.alibaba.fastjson.JSON;
 import com.fs.common.constant.LiveKeysConstant;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.utils.DateUtils;
 import com.fs.his.domain.FsUser;
@@ -14,6 +15,7 @@ import com.fs.live.domain.Live;
 import com.fs.live.domain.LiveWatchUser;
 import com.fs.live.mapper.LiveWatchUserMapper;
 import com.fs.live.service.ILiveWatchUserService;
+import com.fs.live.vo.LiveWatchUserStatistics;
 import com.fs.live.vo.LiveWatchUserVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -76,6 +78,13 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
     @Override
     public List<LiveWatchUser> selectLiveWatchUserList(LiveWatchUser liveWatchUser)
     {
+        if ("online".equals(liveWatchUser.getTabName())) {
+            liveWatchUser.setOnline(0);
+        } else if ("offline".equals(liveWatchUser.getTabName())) {
+            liveWatchUser.setOnline(1);
+        } else if ("silenced".equals(liveWatchUser.getTabName())) {
+            liveWatchUser.setMsgStatus(1);
+        }
         return baseMapper.selectLiveWatchUserList(liveWatchUser);
     }
 
@@ -162,6 +171,14 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
     @Override
     public LiveWatchUser close(long liveId, long userId) {
         LiveWatchUser liveWatchUser = getByLiveIdAndUserId(liveId, userId);
+        // 设置在线时长
+        try {
+            Long onlineSeconds = liveWatchUser.getOnlineSeconds();
+            if(onlineSeconds == null) onlineSeconds = 0L;
+            liveWatchUser.setOnlineSeconds(onlineSeconds + (System.currentTimeMillis() - liveWatchUser.getUpdateTime().getTime()));
+        } catch (Exception e) {
+            log.error("设置在线时长异常:{}", e.getMessage());
+        }
         liveWatchUser.setUpdateTime(DateUtils.getNowDate());
         liveWatchUser.setOnline(1);
         baseMapper.updateLiveWatchUser(liveWatchUser);
@@ -227,8 +244,8 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
     }
 
     @Override
-    public List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId,Integer totalLots) {
-        return baseMapper.selectLiveWatchAndRegisterUser(liveId, lotteryId,totalLots);
+    public List<LiveWatchUser> selectLiveWatchAndRegisterUser(Long liveId, Long lotteryId) {
+        return baseMapper.selectLiveWatchAndRegisterUser(liveId, lotteryId);
     }
 
     @Override
@@ -255,4 +272,28 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
         return liveWatchUserVOS;
     }
 
+    @Override
+    public R liveUserTotals(LiveWatchUser liveWatchUser) {
+        LiveWatchUserStatistics liveWatchUserStatistics = baseMapper.liveUserTotals(liveWatchUser);
+        if(liveWatchUserStatistics == null)
+        {
+            liveWatchUserStatistics = new LiveWatchUserStatistics();
+            liveWatchUserStatistics.setOnline(0);
+            liveWatchUserStatistics.setOffline(0);
+            liveWatchUserStatistics.setSilenced(0);
+            return R.ok().put("data", liveWatchUserStatistics);
+        }
+        if(liveWatchUserStatistics.getOnline() == null)
+        {
+            liveWatchUserStatistics.setOnline(0);
+        }
+        if (liveWatchUserStatistics.getOffline() == null) {
+            liveWatchUserStatistics.setOffline(0);
+        }
+        if (liveWatchUserStatistics.getSilenced() == null) {
+            liveWatchUserStatistics.setSilenced(0);
+        }
+        return R.ok().put("data", liveWatchUserStatistics);
+    }
+
 }

+ 1 - 1
fs-service/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;
 
     /**
      * 仓库代码

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

@@ -37,6 +37,8 @@ public class LiveUserLotteryRecordVo extends BaseEntity{
 
     private String userName;
     private String productName;
+    private Long orderId;
+    private Integer orderStatus;
 
 
 }

+ 11 - 0
fs-service/src/main/java/com/fs/live/vo/LiveWatchUserStatistics.java

@@ -0,0 +1,11 @@
+package com.fs.live.vo;
+
+import lombok.Data;
+
+@Data
+public class LiveWatchUserStatistics {
+
+    private Integer online;
+    private Integer offline;
+    private Integer silenced;
+}

+ 6 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -454,6 +454,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{productId}
         </foreach>
     </select>
+    <select id="selectFsStoreProductByProductIds" resultMap="FsStoreProductResult">
+        select * from fs_store_product_scrm where product_id in
+        <foreach item="productId" collection="productIds" open="(" separator="," close=")">
+            #{productId}
+        </foreach>
+    </select>
     <select id="selectFsStoreProductNewQuery" resultType="com.fs.hisStore.vo.FsStoreProductListQueryVO">
         select p.* from fs_store_product_scrm p
         <if test='config.isAudit == "1"'>

+ 58 - 4
fs-service/src/main/resources/mapper/live/LiveAutoTaskMapper.xml

@@ -1,7 +1,7 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveAutoTaskMapper">
 
     <resultMap type="LiveAutoTask" id="LiveAutoTaskResult">
@@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="finishStatus != null">finish_status,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
             <if test="taskName != null and taskName != ''">#{taskName},</if>
@@ -73,7 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="finishStatus != null">#{finishStatus},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateLiveAutoTask" parameterType="LiveAutoTask">
@@ -112,4 +112,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
         and status=1 and finish_status = 0 and abs_value>#{now} order by abs_value
     </select>
+    <insert id="batchInsertLiveAutoTask" parameterType="java.util.List">
+        INSERT INTO live_auto_task (
+        live_id,
+        task_name,
+        task_type,
+        trigger_type,
+        trigger_value,
+        abs_value,
+        content,
+        status,
+        finish_status,
+        create_time,
+        update_time
+        )
+        VALUES
+        <foreach collection="list" item="task" separator=",">
+            (
+            #{task.liveId},
+            #{task.taskName},
+            #{task.taskType},
+            #{task.triggerType},
+            #{task.triggerValue},
+            #{task.absValue},
+            #{task.content},
+            #{task.status},
+            #{task.finishStatus},
+            #{task.createTime},
+            #{task.updateTime}
+            )
+        </foreach>
+    </insert>
+
+    <!-- 批量更新直播间自动化任务 -->
+    <update id="batchUpdateLiveAutoTask">
+        <foreach collection="list" item="task" separator=";">
+            UPDATE live_auto_task
+            <set>
+                <!-- 1. 按需添加需更新的字段,非必更新字段用 if 判断(避免更新为 null) -->
+                <if test="task.liveId != null">live_id = #{task.liveId},</if>
+                <if test="task.taskName != null and task.taskName != ''">task_name = #{task.taskName},</if>
+                <if test="task.taskType != null">task_type = #{task.taskType},</if>
+                <if test="task.triggerType != null">trigger_type = #{task.triggerType},</if>
+                <if test="task.triggerValue != null">trigger_value = #{task.triggerValue},</if>
+                <if test="task.absValue != null">abs_value = #{task.absValue},</if>
+                <if test="task.content != null and task.content != ''">content = #{task.content},</if>
+                <if test="task.status != null">status = #{task.status},</if>
+                <if test="task.finishStatus != null">finish_status = #{task.finishStatus},</if>
+                <!-- 2. 若有更新时间字段,自动填充当前时间 -->
+                update_time = NOW()
+            </set>
+            <!-- 3. 必须通过主键 id 定位数据(批量更新的核心) -->
+            WHERE id = #{task.id}
+        </foreach>
+    </update>
 </mapper>

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

@@ -42,9 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveCartListVo" parameterType="LiveCart" resultType="com.fs.live.vo.LiveCartVo">
         select a.cart_id, a.live_id, a.user_id, a.goods_id, a.product_id, a.product_attr_value_id, a.cart_num, a.create_time, a.update_time, a.is_pay, a.is_del, a.is_buy,a.checked,
-        b.product_name, b.img_url,b.price, b.ot_price, b.stock,b.sales
+        b.product_name, b.image as img_url,b.price, b.ot_price, b.stock,b.sales
         from live_cart a
-        left join fs_store_product b on a.product_id = b.product_id
+        left join fs_store_product_scrm b on a.product_id = b.product_id
         <where>
             <if test="liveId != null "> and live_id = #{liveId}</if>
             <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>

+ 20 - 18
fs-service/src/main/resources/mapper/live/LiveGoodsMapper.xml

@@ -1,7 +1,7 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveGoodsMapper">
 
     <resultMap type="LiveGoods" id="LiveGoodsResult">
@@ -66,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="sort != null">sort,</if>
             <if test="isShow != null">is_show,</if>
             <if test="sales != null">sales,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
             <if test="companyId != null">#{companyId},</if>
@@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="sort != null">#{sort},</if>
             <if test="isShow != null">#{isShow},</if>
             <if test="sales != null">#{sales},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateLiveGoods" parameterType="LiveGoods">
@@ -170,11 +170,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectProductListByLiveId" parameterType="LiveGoods" resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.images as img_url,sp.product_name,sp.price,sp.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,case when lg.is_show = 1 then true else false end as is_show
+        select lg.goods_id,sp.image as img_url,sp.product_name,sp.price,sp.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,case when lg.is_show = 1 then true else false end as is_show
         <if test="companyUserId != null "> ,if(uf.favorite_id is not null, true, false) is_favorite </if>
 
         from live_goods lg
-        left join fs_store_product sp
+        left join fs_store_product_scrm sp
         ON  lg.product_id = sp.product_id
         <if test="companyUserId != null "> left join live_user_favorite uf on uf.product_id = lg.goods_id and uf.user_id = #{companyUserId} </if>
 
@@ -197,9 +197,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectProductListByLiveIdAll" parameterType="LiveGoods" resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.images as img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,case when lg.is_show = 1 then true else false end as is_show,sp.is_show as fs_status
+        select lg.goods_id,sp.image as img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price,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
+        left join fs_store_product_scrm sp
         ON  lg.product_id = sp.product_id
 
         <where>
@@ -217,9 +217,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveGoodsVoByGoodsId"  resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.images as img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price, case when lg.is_show = 1 then true else false end as is_show,sp.is_show as fs_status
+        select lg.goods_id,sp.image as img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price, 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
+        left join fs_store_product_scrm sp
         ON  lg.product_id = sp.product_id
 
         <where>
@@ -229,9 +229,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="showGoods"  resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.images as img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price, case when lg.is_show = 1 then true else false end as is_show,sp.is_show as fs_status
+        select lg.goods_id,sp.image as img_url,sp.product_name,sp.price,lg.stock,lg.sales,lg.status,sp.product_id,sp.ot_price, 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
+        left join fs_store_product_scrm sp
         ON  lg.product_id = sp.product_id
         <where>
             lg.live_id = #{liveId} and lg.is_show = 1
@@ -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.images 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
-        from fs_store_product sp
+        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_scrm sp
+        left join fs_store_product_attr_value_scrm pav
+        ON  sp.product_id = pav.product_id
         <where>
             sp.product_id = #{productId}
         </where>
@@ -265,11 +267,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveGoodsListByStoreId" resultType="com.fs.live.vo.LiveGoodsVo">
         select
-            g.*,
-            if(uf.favorite_id is not null, true, false) isFavorite,
-            p.images as img_url, p.product_name, p.price, g.sales, p.ot_price,p.is_show as fs_status
+        g.*,
+        if(uf.favorite_id is not null, true, false) isFavorite,
+        p.image as 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 fs_store_product_scrm 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}
         where  g.status = 1
         <if test="params.productName != null "> and p.product_name like concat('%',#{params.productName},'%')</if>

+ 7 - 8
fs-service/src/main/resources/mapper/live/LiveLotteryProductConfMapper.xml

@@ -130,14 +130,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveLotteryProductConfByLotteryIds"  resultType="com.fs.live.vo.LiveLotteryProductListVo">
         select llpc.lottery_id,llpc.live_id,llpc.product_id,llpc.prize_level,llpc.per_lottery_num,llpc.total_lots,
-               fs.images as img_url,fs.product_name,fs.price,fs.ot_price,fs.sales,fs.stock
-               from live_lottery_product_conf llpc
-            left join live_goods lg on lg.goods_id = llpc.product_id
-            left join fs_store_product fs on fs.product_id = lg.product_id
-            where llpc.lottery_id in
-            <foreach item="id" collection="lotteryIds" separator="," open="(" close=")">
-                #{id}
-            </foreach>
+        fs.image as img_url,fs.product_name,fs.price,fs.ot_price,fs.sales,fs.stock
+        from live_lottery_product_conf llpc
+        left join fs_store_product_scrm fs on fs.product_id = llpc.product_id
+        where llpc.lottery_id in
+        <foreach item="id" collection="lotteryIds" separator="," open="(" close=")">
+            #{id}
+        </foreach>
     </select>
     <select id="selectEntityByIds"  resultType="com.fs.live.domain.LiveLotteryProductConf">
         select llpc.*

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

@@ -67,9 +67,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectCheckedByUserId" parameterType="java.util.List" resultType="com.fs.live.vo.LiveOrderItemVo">
         select a.item_id, a.order_id, a.order_code, a.cart_id, a.goods_id, a.product_id,a. product_attr_value_id, a.json_info, a.num, a.is_after_sales, a.is_prescribe, a.store_id, a.is_gift
-        , b.product_name, b.images as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce
+        , b.product_name, b.image as img_url, b.price, b.ot_price, b.sales, b.product_info as product_introduce
         from live_order_item a
-        left join fs_store_product b on a.product_id = b.product_id
+        left join fs_store_product_scrm b on a.product_id = b.product_id
         where a.user_id=#{userId}
     </select>
 

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

@@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="storeId"    column="store_id"    />
         <result property="orderCode"    column="order_code"    />
         <result property="userId"    column="user_id"    />
-        <result property="realName"    column="real_name"    />
+        <result property="userName"    column="user_name"    />
         <result property="userPhone"    column="user_phone"    />
         <result property="userAddress"    column="user_address"    />
         <result property="cartId"    column="cart_id"    />
@@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <sql id="selectLiveOrderVo">
         SELECT
-            a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.real_name,
+            a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
             a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
             a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
             a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
@@ -92,14 +92,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
             a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
             a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
-            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_introduce as product_introduce,a.customer_id
+            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
         FROM
-            live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
+            live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
     </sql>
 
-    <select id="selectLiveOrderList" parameterType="LiveOrder" resultMap="LiveOrderResult">
+    <select id="selectLiveOrderList" parameterType="com.fs.live.domain.LiveOrder" resultMap="LiveOrderResult">
         SELECT
-        c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.real_name,
+        c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
         a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
         a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
         a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
@@ -111,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
         a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
         FROM
-        live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
+        live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
         left join company_user cu on a.company_user_id = cu.user_id
         left join company c on a.company_id = c.company_id
         <where>
@@ -121,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="storeId != null "> and store_id = #{storeId}</if>
             <if test="orderCode != null  and orderCode != ''"> and a.order_code = #{orderCode}</if>
             <if test="userId != null  and userId != ''"> and a.user_id = #{userId}</if>
-            <if test="realName != null  and realName != ''"> and a.real_name like concat('%', #{realName}, '%')</if>
+            <if test="realName != null  and realName != ''"> and a.user_name like concat('%', #{realName}, '%')</if>
             <if test="userPhone != null  and userPhone != ''"> and a.user_phone = #{userPhone}</if>
             <if test="userAddress != null  and userAddress != ''"> and a.user_address = #{userAddress}</if>
             <if test="cartId != null  and cartId != ''"> and cart_id = #{cartId}</if>
@@ -187,7 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLiveOrderByOrderId" parameterType="String" resultMap="LiveOrderResult">
         SELECT
-            c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.real_name,
+            c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id,	a.product_id,	a.order_name,	a.store_id,	a.order_code,	a.user_id,	a.user_name,
             a.user_phone,	a.user_address,	a.cart_id,	a.total_num,	a.total_price,	a.pay_price,	a.pay_money,	a.is_pay,
             a.pay_time,	a.pay_type,	a.create_time,	a.update_time,	a.STATUS,	a.refund_status,	a.refund_img,	a.refund_explain,
             a.refund_time,	a.refund_reason,	a.refund_money,	a.delivery_code,	a.delivery_name,	a.delivery_sn,
@@ -199,7 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
             a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
         FROM
-            live_order a LEFT JOIN fs_store_product b ON a.product_id = b.product_id
+            live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
                          left join company_user cu on a.company_user_id = cu.user_id
                          left join company c on a.company_id = c.company_id
         where a.order_id = #{orderId}
@@ -526,7 +526,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and u.nickname like CONCAT('%',#{maps.nickname},'%')
         </if>
         <if test="maps.realName != null and  maps.realName !=''">
-            and o.real_name like CONCAT('%',#{maps.realName},'%')
+            and o.user_name like CONCAT('%',#{maps.realName},'%')
         </if>
         <if test="maps.phone != null and  maps.phone !=''">
             and u.phone like CONCAT('%',#{maps.phone},'%')
@@ -685,7 +685,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and u.nickname like CONCAT('%',#{maps.nickname},'%')
             </if>
             <if test="maps.realName != null and  maps.realName !=''">
-                and o.real_name like CONCAT('%',#{maps.realName},'%')
+                and o.user_name like CONCAT('%',#{maps.realName},'%')
             </if>
             <if test="maps.phone != null and  maps.phone !=''">
                 and u.phone like CONCAT('%',#{maps.phone},'%')
@@ -826,7 +826,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and u.nickname like CONCAT('%',#{maps.nickname},'%')
             </if>
             <if test="maps.realName != null and  maps.realName !=''">
-                and o.real_name like CONCAT('%',#{maps.realName},'%')
+                and o.user_name like CONCAT('%',#{maps.realName},'%')
             </if>
             <if test="maps.phone != null and  maps.phone !=''">
                 and u.phone like CONCAT('%',#{maps.phone},'%')

+ 19 - 10
fs-service/src/main/resources/mapper/live/LiveUserLotteryRecordMapper.xml

@@ -1,7 +1,7 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveUserLotteryRecordMapper">
 
     <resultMap type="LiveUserLotteryRecord" id="LiveUserLotteryRecordResult">
@@ -14,19 +14,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateBy"    column="update_by"    />
+        <result property="orderId"    column="order_id"    />
+        <result property="orderStatus"    column="order_status"    />
     </resultMap>
 
     <sql id="selectLiveUserLotteryRecordVo">
-        select id, lottery_id, live_id, user_id, product_id, create_time, update_time, create_by, update_by from live_user_lottery_record
+        select id, lottery_id, live_id, user_id, product_id, create_time, update_time, create_by, update_by,order_id,order_status from live_user_lottery_record
     </sql>
 
-    <select id="selectLiveUserLotteryRecordList" parameterType="LiveUserLotteryRecord" resultMap="LiveUserLotteryRecordResult">
+    <select id="selectLiveUserLotteryRecordList" parameterType="com.fs.live.domain.LiveUserLotteryRecord" resultMap="LiveUserLotteryRecordResult">
         <include refid="selectLiveUserLotteryRecordVo"/>
         <where>
             <if test="liveId != null "> and live_id = #{liveId}</if>
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="productId != null "> and product_id = #{productId}</if>
             <if test="createTime != null "> and create_time = #{createTime}</if>
+            <if test="orderId != null "> and order_id = #{orderId}</if>
+            <if test="orderStatus != null "> and order_status = #{orderStatus}</if>
         </where>
     </select>
 
@@ -37,12 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectRecordByLiveIdAndLotteryId"  resultType="com.fs.live.vo.LiveUserLotteryRecordVo">
         select lulr.*,fu.nickname as user_name,fsp.product_name as product_name
         from live_user_lottery_record lulr left join fs_user fu on lulr.user_id = fu.user_id
-        left join live_goods lg on lulr.product_id = lg.goods_id
-        left join fs_store_product fsp on lg.product_id = fsp.product_id
+                                           left join fs_store_product_scrm fsp on lulr.product_id = fsp.product_id
         where lulr.lottery_id = #{lotteryId} and lulr.live_id = #{liveId}
     </select>
 
-    <insert id="insertLiveUserLotteryRecord" parameterType="LiveUserLotteryRecord" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertLiveUserLotteryRecord" parameterType="com.fs.live.domain.LiveUserLotteryRecord" useGeneratedKeys="true" keyProperty="id">
         insert into live_user_lottery_record
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="lotteryId != null">lottery_id,</if>
@@ -53,7 +56,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
-         </trim>
+            <if test="orderId != null">order_id,</if>
+            <if test="orderStatus != null">order_status,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="lotteryId != null">#{lotteryId},</if>
             <if test="liveId != null">#{liveId},</if>
@@ -63,10 +68,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">#{updateTime},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
-         </trim>
+            <if test="orderId != null">#{orderId},</if>
+            <if test="orderStatus != null">#{orderStatus},</if>
+        </trim>
     </insert>
 
-    <update id="updateLiveUserLotteryRecord" parameterType="LiveUserLotteryRecord">
+    <update id="updateLiveUserLotteryRecord" parameterType="com.fs.live.domain.LiveUserLotteryRecord">
         update live_user_lottery_record
         <trim prefix="SET" suffixOverrides=",">
             <if test="lotteryId != null">lottery_id = #{lotteryId},</if>
@@ -77,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="orderId != null">order_id = #{orderId},</if>
+            <if test="orderStatus != null">order_status = #{orderStatus},</if>
         </trim>
         where id = #{id}
     </update>

+ 23 - 14
fs-service/src/main/resources/mapper/live/LiveWatchUserMapper.xml

@@ -1,7 +1,7 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.live.mapper.LiveWatchUserMapper">
 
     <resultMap type="LiveWatchUser" id="LiveWatchUserResult">
@@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="remark"    column="remark"    />
+        <result property="onlineSeconds"    column="online_seconds"    />
     </resultMap>
 
     <sql id="selectLiveWatchUserVo">
-        select id, live_id,user_id, msg_status, online, create_time, create_by, update_by, update_time, remark from live_watch_user
+        select id, live_id,user_id, msg_status, online, create_time, create_by, update_by, update_time, remark,online_seconds from live_watch_user
     </sql>
 
     <select id="selectLiveWatchUserList" parameterType="LiveWatchUser" resultMap="LiveWatchUserResult">
@@ -28,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="msgStatus != null "> and msg_status = #{msgStatus}</if>
             <if test="online != null "> and online = #{online}</if>
+            <if test="onlineSeconds != null "> and online_seconds = #{onlineSeconds}</if>
         </where>
     </select>
 
@@ -38,16 +40,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectWatchUserListByLiveId" resultType="com.fs.live.vo.LiveWatchUserVO">
         select
-            lwu.live_id     liveId,
-            lwu.user_id     userId,
-            lwu.msg_status  msgStatus,
-            lwu.online      online,
-            fu.nickname    nickName,
-            fu.avatar       avatar
+        lwu.live_id     liveId,
+        lwu.user_id     userId,
+        lwu.msg_status  msgStatus,
+        lwu.online      online,
+        fu.nickname    nickName,
+        fu.avatar       avatar
         from live_watch_user lwu
         left join fs_user fu on lwu.user_id = fu.user_id
         where lwu.live_id = #{params.liveId}
+        <if test="params.msgStatus != null "> and msg_status = #{params.msgStatus}</if>
+        <if test="params.online != null "> and online = #{params.online}</if>
         order by lwu.create_time desc
+
     </select>
 
     <select id="selectLiveWatchUserByIdAndCompanyIdAndCompanyUserId" resultMap="LiveWatchUserResult">
@@ -64,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             fu.nickname    nickName,
             fu.avatar       avatar
         from live_watch_user lwu
-        left join fs_user fu on lwu.user_id = fu.user_id
+                 left join fs_user fu on lwu.user_id = fu.user_id
         where lwu.live_id = #{liveId} and lwu.user_id = #{userId}
     </select>
 
@@ -76,8 +81,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from live_watch_user lwu
         left join fs_user fu on lwu.user_id = fu.user_id
         <where>
-        <if test="liveId != null "> and live_id = #{liveId}</if>
-        <if test="online != null "> and online = #{online}</if>
+            <if test="liveId != null "> and live_id = #{liveId}</if>
+            <if test="online != null "> and online = #{online}</if>
         </where>
     </select>
 
@@ -93,7 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
-         </trim>
+            <if test="onlineSeconds != null">online_seconds,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
             <if test="userId != null">#{userId},</if>
@@ -104,7 +110,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
-         </trim>
+            <if test="onlineSeconds != null">#{onlineSeconds},</if>
+        </trim>
     </insert>
 
     <update id="updateLiveWatchUser" parameterType="LiveWatchUser">
@@ -119,6 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="onlineSeconds != null">online_seconds = #{onlineSeconds},</if>
         </trim>
         where id = #{id}
     </update>
@@ -144,6 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             FROM live_reward_record lrr
             WHERE lrr.user_id = lwu.user_id
               AND lrr.live_id = lwu.live_id
+              and lrr.source_type = 3
               AND DATE(lrr.create_time) = DATE(#{now})
         )
     </select>

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/live/LiveAfterSalesController.java

@@ -50,7 +50,7 @@ public class LiveAfterSalesController extends AppBaseController {
     private ILiveOrderService orderService;
     @Login
     @ApiOperation("获取订单项列表")
-    @GetMapping({"/getStoreOrderItems", "/getMyStoreOrderItemByOrderId"})
+    @GetMapping("/getStoreOrderItems")
     public R getMyStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
         List<LiveOrderItem> list=itemService.selectCheckedByOrderId(orderId);
         LiveOrder order=orderService.selectLiveOrderByOrderId(String.valueOf(orderId));

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/live/LiveController.java

@@ -34,7 +34,7 @@ import java.util.Map;
 
 
 @Api("直播信息接口")
-@RestController
+@RestController("AppLiveController")
 @AllArgsConstructor
 @RequestMapping(value="/app/live")
 public class LiveController extends AppBaseController {

+ 2 - 1
fs-user-app/src/main/java/com/fs/app/controller/live/LiveGoodsController.java

@@ -9,6 +9,7 @@ import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.his.service.IFsStoreProductService;
+import com.fs.hisStore.service.IFsStoreProductScrmService;
 import com.fs.live.domain.LiveGoods;
 import com.fs.live.service.ILiveGoodsService;
 import com.github.pagehelper.PageHelper;
@@ -32,7 +33,7 @@ public class LiveGoodsController extends AppBaseController
     private ILiveGoodsService liveGoodsService;
 
     @Autowired
-    private IFsStoreProductService fsStoreProductService;
+    private IFsStoreProductScrmService fsStoreProductService;
 
     @Autowired
     private RedisCache redisCache;

+ 73 - 0
fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

@@ -139,6 +139,38 @@ public class LiveOrderController extends AppBaseController
     @Autowired
     private JwtUtils jwtUtils;
 
+    /**
+     * 查询订单列表
+     */
+    @Login
+    @GetMapping("/list")
+    public R list(LiveOrder liveOrder)
+    {
+        log.info("查询订单列表 参数: {}", JSON.toJSONString(liveOrder));
+
+        PageHelper.startPage(Integer.parseInt(ServletUtils.getParameter("pageNum")) ,Integer.parseInt(ServletUtils.getParameter("pageSize")) );
+        try {
+            liveOrder.setUserId(getUserId());
+            List<LiveOrderListVo> list = orderService.selectLiveOrderListVo(liveOrder);
+            PageInfo<LiveOrderListVo> result = new PageInfo<>(list);
+            return R.ok().put("data", result);
+        } catch (Exception e) {
+            log.error("查询失败!",e);
+            return R.error("操作异常");
+        }
+
+    }
+
+    /**
+     *正在购买的用户
+     * */
+    @GetMapping(value = "/liveOrderUser/{liveId}")
+    public R liveOrderUser(@PathVariable  String liveId)
+    {
+        log.info("正在购买的用户 参数: {}",liveId);
+        return orderService.liveOrderUser(liveId);
+    }
+
 
     @Login
     @ApiOperation("获取我的订单列表")
@@ -234,12 +266,53 @@ public class LiveOrderController extends AppBaseController
         return R.ok().put("data",dto);
     }
 
+    @Login
+    @ApiOperation("计算中奖订单")
+    @PostMapping("/computedReward")
+    public R computedReward(@Validated @RequestBody LiveOrderComputedParam param){
+        log.info("计算中奖订单 {}",JSON.toJSONString(param));
+
+        LiveOrderComputeDTO dto=orderService.computedReward(Long.parseLong(getUserId()),param);
+        return R.ok().put("data",dto);
+    }
+
+    /**
+     * 新增中奖订单
+     */
+    @Login
+    @Log(title = "新增中奖订单", businessType = BusinessType.INSERT)
+    @PostMapping("/createReward")
+    @RepeatSubmit
+    public R createReward(@RequestBody LiveOrder liveOrder)
+    {
+        log.info("新增中奖订单: {}", JSON.toJSONString(liveOrder));
+
+        liveOrder.setUserId(getUserId());
+        return orderService.createRewardLiveOrder(liveOrder);
+    }
+
+    /**
+     * 新增订单
+     */
+    @Login
+    @Log(title = "提交中奖订单", businessType = BusinessType.INSERT)
+    @PostMapping("/payConfirmReward")
+    @RepeatSubmit
+    public R payConfirmReward(@RequestBody LiveOrder liveOrder)
+    {
+        log.info("新增订单: {}", JSON.toJSONString(liveOrder));
+
+        liveOrder.setUserId(getUserId());
+        return orderService.payConfirmReward(liveOrder);
+    }
+
     @Login
     @ApiOperation("创建订单")
     @PostMapping("/create")
     public R create(@Validated @RequestBody LiveOrder param, HttpServletRequest request){
         String userId= getUserId();
         log.info("开始创建订单,登录用户id:{}", userId);
+        param.setUserId(userId);
         return orderService.createLiveOrder(param);
     }
 

+ 18 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/AddressScrmController.java

@@ -7,6 +7,8 @@ import com.fs.app.controller.AppBaseController;
 import com.fs.app.utils.CityTreeUtil;
 import com.fs.app.vo.CityVO;
 import com.fs.common.core.domain.R;
+import com.fs.common.utils.ParseUtils;
+import com.fs.his.domain.FsUserAddress;
 import com.fs.hisStore.domain.FsCityScrm;
 import com.fs.hisStore.domain.FsUserAddressScrm;
 import com.fs.hisStore.param.*;
@@ -152,4 +154,20 @@ public class AddressScrmController extends AppBaseController {
         return R.ok("操作成功");
     }
 
+    @Login
+    @ApiOperation("获取默认地址信息")
+    @GetMapping("/getAddressByDefault")
+    public R getAddressByDefault( HttpServletRequest request){
+        FsUserAddress address=addressService.selectFsUserAddressByDefault(Long.parseLong(getUserId()));
+        if (address!=null&&address.getPhone()!=null&&address.getPhone().length()>11&&!address.getPhone().matches("\\d+")){
+            address.setPhone(ParseUtils.parsePhone(address.getPhone()));
+        }
+        if (null!=address){
+            if(!address.getUserId().equals(Long.parseLong(getUserId()))){
+                return R.error("非法操作");
+            }
+        }
+        return R.ok().put("data",address);
+    }
+
 }