ソースを参照

卓美看课挂小黄车

luolinsong 1 週間 前
コミット
e2e44c5218

+ 48 - 1
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -9,6 +9,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.constant.FsConstants;
 import com.fs.common.core.domain.R;
@@ -61,6 +64,7 @@ import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.im.service.OpenIMService;
 import com.fs.qw.domain.*;
 import com.fs.qw.domain.QwCompany;
@@ -252,6 +256,11 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
     @Autowired
     private IFsCourseLinkService linkService;
 
+    @Autowired
+    private FsDepVideoShowMapper fsDepVideoShowMapper;
+
+    @Value("${cloud_host.company_name}")
+    private String companyName;
 
     /**
      * 查询课堂视频
@@ -2833,7 +2842,9 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
         // 1、获取视频详情、问题详情
         ResponseResult<FsUserCourseVideoDetailsVO> videoDetails = this.getVideoDetails(param.getVideoId());
         FsUserCourseVideoDetailsVO courseVideoDetails = videoDetails.getData() != null ? videoDetails.getData() : null;
-
+        if(courseVideoDetails != null && "北京卓美".equals(companyName)){
+            getGoodsAndShow(param.getVideoId(),courseVideoDetails);
+        }
         //课程logo
         if (param.getPeriodId() != null) {
             FsUserCoursePeriod fsUserCoursePeriod = fsUserCoursePeriodMapper.selectFsUserCoursePeriodById(param.getPeriodId());
@@ -4516,5 +4527,41 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
     public List<OptionsVO> selectVideoOptionsByCourseId(Long courseId) {
         return fsUserCourseVideoMapper.selectVideoOptionsByCourseId(courseId);
     }
+
+    /**
+     * 小黄车商品和展示
+     */
+    private void getGoodsAndShow(Long videoId, FsUserCourseVideoDetailsVO vo) {
+        String show = fsDepVideoShowMapper.selectFsDepVideoShowByVideoId(videoId, null);
+        vo.setShowProduct(show);
+
+        FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
+        String packageJson = courseVideo.getPackageJson();
+        if (StringUtils.isNotEmpty(packageJson)) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            JsonNode jsonNode = null;
+            try {
+                jsonNode = objectMapper.readTree(packageJson);
+            } catch (JsonProcessingException e) {
+                throw new RuntimeException(e);
+            }
+            if (jsonNode.isArray()) {
+                List<FsStoreProductScrm> fsPackageListVOS = new ArrayList<>();
+                for (JsonNode node : jsonNode) {
+                    FsStoreProductScrm fsStoreProductScrm = new FsStoreProductScrm();
+                    fsStoreProductScrm.setProductId(node.path("productId").asLong());
+                    fsStoreProductScrm.setImages(node.path("image").asText());
+                    fsStoreProductScrm.setImgUrl(node.path("imgUrl").asText());
+                    fsStoreProductScrm.setBarCode(node.path("barCode").asText());
+                    fsStoreProductScrm.setPrice(new BigDecimal(node.path("price").asText()));
+                    fsStoreProductScrm.setProductName(node.path("productName").asText());
+                    fsPackageListVOS.add(fsStoreProductScrm);
+                }
+                vo.setFsStoreProductScrms(fsPackageListVOS);
+            }
+        } else {
+            vo.setFsStoreProductScrms(new ArrayList<>());
+        }
+    }
 }
 

+ 13 - 0
fs-service/src/main/java/com/fs/course/vo/FsUserCourseVideoH5DVO.java

@@ -1,8 +1,12 @@
 package com.fs.course.vo;
 
 import com.fs.common.core.domain.BaseEntity;
+import com.fs.course.domain.FsCourseProduct;
+import com.fs.hisStore.domain.FsStoreProductScrm;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * 课堂视频对象 fs_user_video
  *
@@ -51,4 +55,13 @@ public class FsUserCourseVideoH5DVO extends BaseEntity
 
     private Long listingEndTime;//商品结束售卖时间
 
+    /**
+     * 是否展示商品 0展示 1不展示
+     */
+    private String showProduct;
+
+    /**
+     * 商品列表
+     */
+    private List<FsStoreProductScrm> fsStoreProductScrms;
 }

+ 10 - 0
fs-service/src/main/java/com/fs/course/vo/newfs/FsUserCourseVideoDetailsVO.java

@@ -1,5 +1,6 @@
 package com.fs.course.vo.newfs;
 
+import com.fs.hisStore.domain.FsStoreProductScrm;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -39,4 +40,13 @@ public class FsUserCourseVideoDetailsVO {
     @ApiModelProperty(value = "题库内容")
     private List<FsUserVideoQuestionVO> questionBankList;
 
+
+    /**
+     * 商品列表
+     */
+    private List<FsStoreProductScrm> fsStoreProductScrms;
+    /**
+     * 是否展示商品 0展示 1不展示
+     */
+    private String showProduct;
 }

+ 56 - 2
fs-user-app/src/main/java/com/fs/app/controller/course/CourseQwController.java

@@ -3,6 +3,9 @@ package com.fs.app.controller.course;
 
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fs.app.annotation.Login;
 import com.fs.app.annotation.UserOperationLog;
 import com.fs.app.controller.AppBaseController;
@@ -15,6 +18,8 @@ import com.fs.course.config.CourseConfig;
 import com.fs.course.domain.FsCourseQuestionBank;
 import com.fs.course.domain.FsCourseWatchLog;
 import com.fs.course.domain.FsUserCourseVideo;
+import com.fs.course.mapper.FsDepVideoShowMapper;
+import com.fs.course.mapper.FsUserCourseVideoMapper;
 import com.fs.course.param.*;
 import com.fs.course.service.*;
 import com.fs.course.service.impl.TencentCloudCosService;
@@ -22,6 +27,7 @@ import com.fs.course.vo.*;
 import com.fs.fastGpt.service.IFastgptEventLogTotalService;
 import com.fs.his.enums.FsUserOperationEnum;
 import com.fs.his.service.IFsIntegralGoodsService;
+import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.sop.domain.QwSop;
 import com.fs.sop.service.IQwSopService;
 import com.fs.system.service.ISysConfigService;
@@ -39,10 +45,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -83,6 +91,13 @@ public class CourseQwController extends AppBaseController {
     @Autowired
     private IQwSopService qwSopService;
 
+    @Autowired
+    private FsDepVideoShowMapper fsDepVideoShowMapper;
+    @Autowired
+    private FsUserCourseVideoMapper fsUserCourseVideoMapper;
+    @Value("${cloud_host.company_name}")
+    private String companyName;
+
     @ApiOperation("查询全部公域的课程")
     @GetMapping("/getAppletCourse")
     public R getAppletCourse()
@@ -171,6 +186,9 @@ public class CourseQwController extends AppBaseController {
             if (log.getLogType()==2){
                 isFinish=1;
             }
+            if ("北京卓美".equals(companyName)){
+                getGoodsAndShow(param, course);
+            }
 
             //将视频时长也存到redis
             String videoRedisKey = "h5user:video:duration:" + param.getVideoId();
@@ -206,7 +224,9 @@ public class CourseQwController extends AppBaseController {
             if (log.getLogType()==2){
                 isFinish=1;
             }
-
+            if ("北京卓美".equals(companyName)){
+                getGoodsAndShow(param, course);
+            }
             return R.ok().put("course",course).put("questions",questionVOList).put("config",config).put("playDuration",duration).put("isFinish",isFinish);
         }
 
@@ -492,5 +512,39 @@ public class CourseQwController extends AppBaseController {
         fastgptEventLogTotalService.eventLogTotals(startTime,endTime);
         return R.ok();
     }
-
+    /**
+     * 小黄车商品和展示
+     */
+    private void getGoodsAndShow(FsUserCourseVideoFinishUParam param, FsUserCourseVideoH5DVO course) {
+        Long videoId = param.getVideoId();
+        String show = fsDepVideoShowMapper.selectFsDepVideoShowByVideoId(videoId, null);
+        course.setShowProduct(show);
+        FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
+        String packageJson = courseVideo.getPackageJson();
+        if (StringUtils.isNotEmpty(packageJson)) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            JsonNode jsonNode = null;
+            try {
+                jsonNode = objectMapper.readTree(packageJson);
+            } catch (JsonProcessingException e) {
+                throw new RuntimeException(e);
+            }
+            if (jsonNode.isArray()) {
+                List<FsStoreProductScrm> fsStoreProductScrms = new ArrayList<>();
+                for (JsonNode node : jsonNode) {
+                    FsStoreProductScrm fsStoreProductScrm = new FsStoreProductScrm();
+                    fsStoreProductScrm.setProductId(node.path("productId").asLong());
+                    fsStoreProductScrm.setImages(node.path("image").asText());
+                    fsStoreProductScrm.setImgUrl(node.path("imgUrl").asText());
+                    fsStoreProductScrm.setBarCode(node.path("barCode").asText());
+                    fsStoreProductScrm.setPrice(new BigDecimal(node.path("price").asText()));
+                    fsStoreProductScrm.setProductName(node.path("productName").asText());
+                    fsStoreProductScrms.add(fsStoreProductScrm);
+                }
+                course.setFsStoreProductScrms(fsStoreProductScrms);
+            }
+        } else {
+            course.setFsStoreProductScrms(new ArrayList<>());
+        }
+    }
 }