فهرست منبع

销售端直播数据展示

yuhongqi 2 روز پیش
والد
کامیت
509faed019

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

@@ -112,7 +112,7 @@ public class LiveDataController {
     @PreAuthorize("@ss.hasPermi('liveData:liveData:query')")
     @GetMapping("/getLiveUserDetailListBySql")
     public R getLiveUserDetailListBySql(@RequestParam Long liveId) {
-        return liveDataService.getLiveUserDetailListBySql(liveId);
+        return liveDataService.getLiveUserDetailListBySql(liveId,null,null);
     }
 
     /**
@@ -147,7 +147,7 @@ public class LiveDataController {
     @Log(title = "直播间用户详情", businessType = BusinessType.EXPORT)
     @GetMapping("/exportLiveUserDetail")
     public AjaxResult exportLiveUserDetail(@RequestParam Long liveId) {
-        List<LiveUserDetailExportVO> list = liveDataService.exportLiveUserDetail(liveId);
+        List<LiveUserDetailExportVO> list = liveDataService.exportLiveUserDetail(liveId,null,null);
         if (list == null || list.isEmpty()) {
             return AjaxResult.error("未找到用户详情数据");
         }

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

@@ -7,6 +7,7 @@ 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;
+import com.fs.company.domain.CompanyUser;
 import com.fs.core.security.LoginUser;
 import com.fs.core.security.SecurityUtils;
 import com.fs.core.web.service.TokenService;
@@ -68,8 +69,10 @@ public class LiveDataController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('liveData:liveData:query')")
     @GetMapping("/getLiveUserDetailListBySql")
-    public R getLiveUserDetailListBySql(@RequestParam Long liveId) {
-        return liveDataService.getLiveUserDetailListBySql(liveId);
+    public R getLiveUserDetailListBySql(@RequestParam Long liveId, HttpServletRequest request) {
+        CompanyUser user = tokenService.getLoginUser(request).getUser();
+
+        return liveDataService.getLiveUserDetailListBySql(liveId,user.getCompanyId(),user.getUserId());
     }
 
     /**
@@ -103,8 +106,9 @@ public class LiveDataController extends BaseController
     @PreAuthorize("@ss.hasPermi('liveData:liveData:export')")
     @Log(title = "直播间用户详情", businessType = BusinessType.EXPORT)
     @GetMapping("/exportLiveUserDetail")
-    public AjaxResult exportLiveUserDetail(@RequestParam Long liveId) {
-        List<LiveUserDetailExportVO> list = liveDataService.exportLiveUserDetail(liveId);
+    public AjaxResult exportLiveUserDetail(@RequestParam Long liveId, HttpServletRequest request) {
+        CompanyUser user = tokenService.getLoginUser(request).getUser();
+        List<LiveUserDetailExportVO> list = liveDataService.exportLiveUserDetail(liveId,user.getCompanyId(),user.getUserId());
         if (list == null || list.isEmpty()) {
             return AjaxResult.error("未找到用户详情数据");
         }

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

@@ -137,7 +137,7 @@ public interface LiveDataMapper {
      * @param liveId 直播间ID
      * @return 用户详情列表
      */
-    List<LiveUserDetailVo> selectLiveUserDetailListBySql(@Param("liveId") Long liveId);
+    List<LiveUserDetailVo> selectLiveUserDetailListBySql(@Param("liveId") Long liveId,@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 
     /**
      * 查询直播间统计数据

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

@@ -143,7 +143,7 @@ public interface ILiveDataService {
      * @param liveId 直播间ID
      * @return 用户详情列表
      */
-    R getLiveUserDetailListBySql(Long liveId);
+    R getLiveUserDetailListBySql(Long liveId, Long companyId, Long companyUserId);
 
     /**
      * 查询直播间详情数据(查询数据服务器处理方式)
@@ -164,7 +164,7 @@ public interface ILiveDataService {
      * @param liveId 直播间ID
      * @return 导出VO列表
      */
-    List<LiveUserDetailExportVO> exportLiveUserDetail(Long liveId);
+    List<LiveUserDetailExportVO> exportLiveUserDetail(Long liveId, Long companyId, Long companyUserId);
 
     R listLiveData(LiveDataParam param);
 }

+ 4 - 4
fs-service-system/src/main/java/com/fs/live/service/impl/LiveDataServiceImpl.java

@@ -583,8 +583,8 @@ public class LiveDataServiceImpl implements ILiveDataService {
     }
 
     @Override
-    public R getLiveUserDetailListBySql(Long liveId) {
-        List<LiveUserDetailVo> userDetailList = liveDataMapper.selectLiveUserDetailListBySql(liveId);
+    public R getLiveUserDetailListBySql(Long liveId, Long companyId, Long companyUserId ) {
+        List<LiveUserDetailVo> userDetailList = liveDataMapper.selectLiveUserDetailListBySql(liveId, companyId, companyUserId);
         return R.ok().put("data", userDetailList);
     }
 
@@ -930,9 +930,9 @@ public class LiveDataServiceImpl implements ILiveDataService {
      * @return 导出VO列表
      */
     @Override
-    public List<LiveUserDetailExportVO> exportLiveUserDetail(Long liveId) {
+    public List<LiveUserDetailExportVO> exportLiveUserDetail(Long liveId, Long companyId, Long companyUserId) {
         // 查询用户详情列表
-        List<LiveUserDetailVo> userDetailList = liveDataMapper.selectLiveUserDetailListBySql(liveId);
+        List<LiveUserDetailVo> userDetailList = liveDataMapper.selectLiveUserDetailListBySql(liveId, companyId, companyUserId);
         if (userDetailList == null || userDetailList.isEmpty()) {
             return new ArrayList<>();
         }

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

@@ -550,6 +550,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                  LEFT JOIN company c ON lufe.company_id = c.company_id
                  LEFT JOIN company_user cu ON lufe.company_user_id = cu.user_id
         WHERE lwu.live_id = #{liveId}
+        <if test="companyId != null">
+            and lufe.company_id = #{companyId}
+        </if>
+        <if test="companyUserId != null">
+            and lufe.company_user_id = #{companyUserId}
+        </if>
         GROUP BY u.user_id, u.nickname, order_info.orderCount, order_info.orderAmount, c.company_name, cu.user_name
         ORDER BY order_info.orderAmount DESC, liveWatchDuration DESC
     </select>

+ 59 - 57
fs-user-app/src/main/java/com/fs/app/controller/LiveGoodsController.java

@@ -142,63 +142,65 @@ public class LiveGoodsController extends AppBaseController
     @GetMapping("/liveGoodsDetail/{productId}")
     public R liveGoodsDetail(@PathVariable Long productId)
     {
-        // 先从缓存中获取商品详情
-        String cacheKey = String.format(LiveKeysConstant.PRODUCT_DETAIL_CACHE, productId);
-        Map<String, Object> cachedData = redisCache.getCacheObject(cacheKey);
-
-        FsStoreProduct product;
-        List<FsStoreProductAttr> productAttr;
-        List<FsStoreProductAttrValue> productValues;
-
-        if (cachedData != null) {
-            // 从缓存中获取数据
-            product = (FsStoreProduct) cachedData.get("product");
-            productAttr = (List<FsStoreProductAttr>) cachedData.get("productAttr");
-            productValues = (List<FsStoreProductAttrValue>) cachedData.get("productValues");
-        } else {
-            // 缓存中没有,从数据库查询
-            product = fsStoreProductService.selectFsStoreProductById(productId);
-            if(product==null){
-                return R.error("商品不存在或已下架");
-            }
-            productAttr = attrService.selectFsStoreProductAttrByProductId(productId);
-            productValues = attrValueService.selectFsStoreProductAttrValueByProductId(productId);
-
-            // 将数据存入缓存
-            Map<String, Object> cacheData = new HashMap<>();
-            cacheData.put("product", product);
-            cacheData.put("productAttr", productAttr);
-            cacheData.put("productValues", productValues);
-            redisCache.setCacheObject(cacheKey, cacheData, LiveKeysConstant.PRODUCT_DETAIL_CACHE_EXPIRE, TimeUnit.SECONDS);
-        }
-
-        // 获取用户的TOKEN写入足迹
-        String userId=getUserId();
-        if(userId!=null){
-            FsStoreProductRelation productRelation=new FsStoreProductRelation();
-            productRelation.setIsDel(0);
-            productRelation.setUserId(Long.parseLong(userId));
-            productRelation.setProductId(product.getProductId());
-            productRelation.setType("foot");
-            List<FsStoreProductRelation> productRelations=productRelationService.selectFsStoreProductRelationList(productRelation);
-            if(productRelations!=null&&productRelations.size()>0){
-                FsStoreProductRelation relation=productRelations.get(0);
-                relation.setUpdateTime(new Date());
-                productRelationService.updateFsStoreProductRelation(relation);
-            }
-            else{
-                FsStoreProductRelation relation=new FsStoreProductRelation();
-                relation.setUserId(Long.parseLong(userId));
-                relation.setIsDel(0);
-                relation.setProductId(product.getProductId());
-                relation.setUpdateTime(new Date());
-                relation.setType("foot");
-                relation.setCreateTime(new Date());
-                relation.setUpdateTime(new Date());
-                productRelationService.insertFsStoreProductRelation(relation);
-            }
-        }
-        return R.ok().put("product",product).put("productAttr",productAttr).put("productValues",productValues);
+        return R.ok().put("data",fsStoreProductService.selectFsStoreProductById(productId));
+
+//        // 先从缓存中获取商品详情
+//        String cacheKey = String.format(LiveKeysConstant.PRODUCT_DETAIL_CACHE, productId);
+//        Map<String, Object> cachedData = redisCache.getCacheObject(cacheKey);
+//
+//        FsStoreProduct product;
+//        List<FsStoreProductAttr> productAttr;
+//        List<FsStoreProductAttrValue> productValues;
+//
+//        if (cachedData != null) {
+//            // 从缓存中获取数据
+//            product = (FsStoreProduct) cachedData.get("product");
+//            productAttr = (List<FsStoreProductAttr>) cachedData.get("productAttr");
+//            productValues = (List<FsStoreProductAttrValue>) cachedData.get("productValues");
+//        } else {
+//            // 缓存中没有,从数据库查询
+//            product = fsStoreProductService.selectFsStoreProductById(productId);
+//            if(product==null){
+//                return R.error("商品不存在或已下架");
+//            }
+//            productAttr = attrService.selectFsStoreProductAttrByProductId(productId);
+//            productValues = attrValueService.selectFsStoreProductAttrValueByProductId(productId);
+//
+//            // 将数据存入缓存
+//            Map<String, Object> cacheData = new HashMap<>();
+//            cacheData.put("product", product);
+//            cacheData.put("productAttr", productAttr);
+//            cacheData.put("productValues", productValues);
+//            redisCache.setCacheObject(cacheKey, cacheData, LiveKeysConstant.PRODUCT_DETAIL_CACHE_EXPIRE, TimeUnit.SECONDS);
+//        }
+//
+//        // 获取用户的TOKEN写入足迹
+//        String userId=getUserId();
+//        if(userId!=null){
+//            FsStoreProductRelation productRelation=new FsStoreProductRelation();
+//            productRelation.setIsDel(0);
+//            productRelation.setUserId(Long.parseLong(userId));
+//            productRelation.setProductId(product.getProductId());
+//            productRelation.setType("foot");
+//            List<FsStoreProductRelation> productRelations=productRelationService.selectFsStoreProductRelationList(productRelation);
+//            if(productRelations!=null&&productRelations.size()>0){
+//                FsStoreProductRelation relation=productRelations.get(0);
+//                relation.setUpdateTime(new Date());
+//                productRelationService.updateFsStoreProductRelation(relation);
+//            }
+//            else{
+//                FsStoreProductRelation relation=new FsStoreProductRelation();
+//                relation.setUserId(Long.parseLong(userId));
+//                relation.setIsDel(0);
+//                relation.setProductId(product.getProductId());
+//                relation.setUpdateTime(new Date());
+//                relation.setType("foot");
+//                relation.setCreateTime(new Date());
+//                relation.setUpdateTime(new Date());
+//                productRelationService.insertFsStoreProductRelation(relation);
+//            }
+//        }
+//        return R.ok().put("product",product).put("productAttr",productAttr).put("productValues",productValues);
 
     }