zyp 3 months ago
parent
commit
6ae0886416

+ 54 - 0
fs-qwhook/src/main/java/com/fs/app/controller/AppBaseController.java

@@ -0,0 +1,54 @@
+package com.fs.app.controller;
+
+
+import com.fs.app.exception.FSException;
+import com.fs.app.utils.JwtUtils;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.ServletUtils;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.service.ICompanyUserService;
+import com.fs.store.domain.FsUser;
+import com.fs.store.service.IFsUserService;
+import io.jsonwebtoken.Claims;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+public class AppBaseController {
+	@Autowired
+	JwtUtils jwtUtils;
+	@Autowired
+	RedisCache redisCache;
+
+	@Autowired
+	private ICompanyUserService companyUserService;
+	@Autowired
+	private IFsUserService userService;
+	public Long getCompanyId() {
+		String headValue =  ServletUtils.getRequest().getHeader("APPToken");
+		Claims claims=jwtUtils.getClaimByToken(headValue);
+		String userId = claims.getSubject().toString();
+		Long companyId =(Long)redisCache.getCacheObject("companyId:"+userId);
+		return companyId;
+	}
+	public String getUserId()
+	{
+		String headValue =  ServletUtils.getRequest().getHeader("APPToken");
+		Claims claims=jwtUtils.getClaimByToken(headValue);
+		String userId = claims.getSubject().toString();
+		return userId;
+	}
+	//获取商城手机号
+	public Long getUserId(Long companyUserId)
+	{
+		CompanyUser companyUser=companyUserService.selectCompanyUserById(companyUserId);
+		FsUser user=userService.selectFsUserByPhone(companyUser.getPhonenumber());
+		if(user==null){
+			throw new FSException("未授权,请用员工手机号登录商城");
+		}
+		return user.getUserId();
+	}
+
+
+
+
+}

+ 72 - 0
fs-qwhook/src/main/java/com/fs/app/controller/FsUserCourseVideoController.java

@@ -0,0 +1,72 @@
+package com.fs.app.controller;
+
+import com.fs.common.core.domain.ResponseResult;
+import com.fs.course.param.newfs.FsUserCourseListParam;
+import com.fs.course.param.newfs.UserCourseVideoPageParam;
+import com.fs.course.service.IFsUserCourseService;
+import com.fs.course.service.IFsUserCourseVideoService;
+import com.fs.course.vo.newfs.FsUserCourseListVO;
+import com.fs.course.vo.newfs.FsUserCourseVideoDetailsVO;
+import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
+import com.fs.course.vo.newfs.FsUserVideoListVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+
+@Api("课程库相关接口")
+@RestController
+@RequestMapping("/app/fs/course")
+@Slf4j
+public class FsUserCourseVideoController extends AppBaseController {
+
+    @Autowired
+    private IFsUserCourseVideoService fsUserCourseVideoService;
+
+    @Autowired
+    private IFsUserCourseService fsUserCourseService;
+
+    @GetMapping("/pageList")
+    @ApiOperation("课程分页列表")
+    public ResponseResult<PageInfo<FsUserCourseVideoPageListVO>> list(UserCourseVideoPageParam param) {
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        param.setCompanyId(getCompanyId());
+        List<FsUserCourseVideoPageListVO> list = fsUserCourseVideoService.pageListCourseVideo(param);
+        PageInfo<FsUserCourseVideoPageListVO> pageInfo = new PageInfo<>(list);
+        return ResponseResult.ok(pageInfo);
+    }
+
+    @ApiOperation("课程视频详情")
+    @GetMapping(value = "/videoDetails")
+    public ResponseResult<FsUserCourseVideoDetailsVO> getVideoDetails(Long videoId) {
+        return fsUserCourseVideoService.getVideoDetails(videoId);
+    }
+
+    @GetMapping("/courseList")
+    @ApiOperation("获取课程下拉列表")
+    public ResponseResult<PageInfo<FsUserCourseListVO>> getAllCourseList(FsUserCourseListParam param) {
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        param.setCompanyId(getCompanyId());
+        List<FsUserCourseListVO> fsUserCourseList = fsUserCourseService.getFsUserCourseList(param);
+        PageInfo<FsUserCourseListVO> pageInfo = new PageInfo<>(fsUserCourseList);
+        return ResponseResult.ok(pageInfo);
+    }
+
+    @GetMapping("/videoList")
+    @ApiOperation("获取视频下拉列表")
+    public ResponseResult<PageInfo<FsUserVideoListVO>> getAllVideoList(UserCourseVideoPageParam param) {
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        param.setCompanyId(getCompanyId());
+        List<FsUserVideoListVO> listCourseVideo = fsUserCourseVideoService.getListCourseVideo(param);
+        PageInfo<FsUserVideoListVO> result = new PageInfo<>(listCourseVideo);
+        return ResponseResult.ok(result);
+    }
+}

+ 4 - 0
fs-service-system/src/main/java/com/fs/course/param/newfs/UserCourseVideoPageParam.java

@@ -26,6 +26,10 @@ public class UserCourseVideoPageParam implements Serializable {
     @ApiModelProperty(value = "公司id")
     private Long companyId;
 
+    private String corpId;
+
+    private String qwUserid;
+
 
 
 //    @ApiModelProperty(value = "视频状态 1:草稿,2:待审核,3:发布")

+ 8 - 8
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -530,12 +530,12 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
                 // 直接插入或更新
 //                logger.error("zyp \n【插入或更新流量】:{}",trafficLog);
-                if(ObjectUtils.isNotNull(trafficLog.getCourseId())) {
-                    FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(trafficLog.getCourseId());
-                    if(ObjectUtils.isNotNull(course)){
-                        trafficLog.setProject(course.getProject());
-                    }
-                }
+//                if(ObjectUtils.isNotNull(trafficLog.getCourseId())) {
+//                    FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(trafficLog.getCourseId());
+//                    if(ObjectUtils.isNotNull(course)){
+//                        trafficLog.setProject(course.getProject());
+//                    }
+//                }
                 fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
             }
         } catch (Exception e) {
@@ -703,7 +703,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             }
             // 添加红包记录
             redPacketLog.setCourseId(param.getCourseId());
-            redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
+//            redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
             redPacketLog.setCompanyId(param.getCompanyId());
             redPacketLog.setUserId(param.getUserId());
             redPacketLog.setVideoId(param.getVideoId());
@@ -720,7 +720,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
                 log.setRewardType(config.getRewardType());
                 courseWatchLogMapper.updateFsCourseWatchLog(log);
             }
-            return R.ok("奖励发放成功");
+            return sendRedPacket;
         } else {
             return R.error("奖励发送失败,请联系客服");
         }

+ 20 - 3
fs-user-app/src/main/java/com/fs/app/controller/CourseH5Controller.java

@@ -5,7 +5,9 @@ import cn.hutool.json.JSONUtil;
 import com.fs.app.annotation.Login;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.domain.R;
+import com.fs.common.utils.StringUtils;
 import com.fs.course.config.CourseConfig;
+import com.fs.course.domain.FsCourseQuestionBank;
 import com.fs.course.domain.FsCourseWatchLog;
 import com.fs.course.param.FsCourseQuestionAnswerUParam;
 import com.fs.course.param.FsCourseSendRewardUParam;
@@ -13,15 +15,19 @@ import com.fs.course.param.FsUserCourseVideoFinishUParam;
 import com.fs.course.service.*;
 import com.fs.course.vo.FsUserCourseVideoH5DVO;
 import com.fs.course.vo.FsUserCourseVideoH5VO;
+import com.fs.course.vo.FsUserCourseVideoQuestionVO;
 import com.fs.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
 
 @Api("h5课堂接口")
 @RestController
@@ -62,11 +68,23 @@ public class CourseH5Controller extends  AppBaseController{
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
         FsUserCourseVideoH5DVO course = courseService.selectFsUserCourseVideoH5DVOByVideoId(param.getVideoId());
 
+        List<FsUserCourseVideoQuestionVO> questionVOList = new ArrayList<>();
+        if (StringUtils.isNotEmpty(course.getQuestionBankId())){
+            String[] questionIds = course.getQuestionBankId().split(",");
+            for (String questionId : questionIds){
+                FsUserCourseVideoQuestionVO vo = new FsUserCourseVideoQuestionVO();
+                FsCourseQuestionBank questionBank = questionBankService.selectFsCourseQuestionBankById(Long.parseLong(questionId));
+                if (questionBank!=null&&questionBank.getStatus()!=0){
+                    BeanUtils.copyProperties(questionBank,vo);
+                    questionVOList.add(vo);
+                }
+            }
+        }
         Long duration = 0L;
         long tipsTime = 0L;
         int isFinish = 0;
         if (param.getLinkType()!=null&&param.getLinkType()==1){
-            return R.ok().put("course",course).put("config",config).put("playDuration",duration).put("tipsTime",tipsTime).put("maxBufferLength",config.getMaxBufferLength());
+            return R.ok().put("course",course).put("questions",questionVOList).put("config",config).put("playDuration",duration).put("tipsTime",tipsTime).put("maxBufferLength",config.getMaxBufferLength());
         }
         // 从Redis中获取观看时长
         String redisKey = "h5user:watch:duration:" + param.getQwUserId()+ ":" + param.getQwExternalId() + ":" + param.getVideoId();
@@ -94,8 +112,7 @@ public class CourseH5Controller extends  AppBaseController{
             redisCache.setCacheObject(videoRedisKey,course.getDuration());
         }
 
-        return R.ok().put("course",course).put("config",config).put("playDuration",duration).put("tipsTime",tipsTime).put("maxBufferLength",config.getMaxBufferLength()).put("isFinish",isFinish);
-    }
+        return R.ok().put("course",course).put("questions",questionVOList).put("config",config).put("playDuration",duration).put("tipsTime",tipsTime).put("maxBufferLength",config.getMaxBufferLength()).put("isFinish",isFinish);    }
 
 
 

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

@@ -14,6 +14,8 @@ import com.fs.qw.mapper.QwExternalContactMapper;
 import com.fs.sop.params.QwSopSettingTimeParam;
 
 import io.swagger.annotations.ApiOperation;
+import lombok.Synchronized;
+import me.chanjar.weixin.common.bean.WxJsapiSignature;
 import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
 import me.chanjar.weixin.common.bean.menu.WxMenu;
 import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
@@ -28,6 +30,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
@@ -146,6 +150,20 @@ public class WxMpController {
 
     }
 
+    @GetMapping("/getWxConfig")
+    @Synchronized
+    public R getWxConfig(@RequestParam String url) throws WxErrorException {
+        try {
+            String sLink = URLDecoder.decode(url, "UTF-8");
+            final WxJsapiSignature jsapiSignature = wxMpService.createJsapiSignature(sLink);
+            return R.ok().put("data", jsapiSignature);
+        } catch (UnsupportedEncodingException e) {
+            // URL解码异常
+            return R.error(e.getMessage());
+        }
+
+    }
+