zyp 1 miesiąc temu
rodzic
commit
04d397c704

+ 1 - 30
fs-service/src/main/java/com/fs/company/mapper/CompanyUserMapper.java

@@ -92,36 +92,7 @@ public interface CompanyUserMapper
     int resetUserPwdByUserId( @Param("userId")Long userId, @Param("password") String encryptPassword);
 
     List<CompanyUser> selectAllUsersList(CompanyUser user);
-    @Select({"<script> " +
-            "select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.open_id,u.id_card, d.dept_name, d.leader, u.is_audit,\n" +
-            "               cr.role_id, cr.role_name\n" +
-            "        from company_user u\n" +
-            "        left join company_user_role cur on cur.user_id = u.user_id\n" +
-            "        left join company_role cr on cr.role_id = cur.role_id\n" +
-            "        left join company_dept d on u.dept_id = d.dept_id\n" +
-            "        where u.del_flag = '0' and u.status=0\n" +
-            "        <if test=\"companyId != null  \">\n" +
-            "            AND u.company_id = #{companyId}\n" +
-            "        </if>\n" +
-            "        <if test=\"nickName != null and nickName != ''\">\n" +
-            "            AND u.nick_name like concat('%', #{nickName}, '%')\n" +
-            "        </if>\n" +
-            "        <if test=\"phonenumber != null and phonenumber != ''\">\n" +
-            "            AND u.phonenumber like concat('%', #{phonenumber}, '%')\n" +
-            "        </if>\n" +
-            "        <if test=\"beginTime != null and beginTime != ''\"><!-- 开始时间检索 -->\n" +
-            "            AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')\n" +
-            "        </if>\n" +
-            "        <if test=\"endTime != null and endTime != ''\"><!-- 结束时间检索 -->\n" +
-            "            AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')\n" +
-            "        </if>\n" +
-            "        <if test=\"deptId != null and deptId != 0\">\n" +
-            "            AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))\n" +
-            "        </if>\n" +
-            "        <if test=\"isAudit != null\">\n" +
-            "            AND u.is_audit = #{isAudit}\n" +
-            "        </if>"+
-            "</script>"})
+
     List<CompanyUserVO> selectMyUserList(CompanyUser user);
     @Select("select u.* from company_user u where u.dept_id in ( SELECT dept_id FROM company_dept WHERE dept_id = #{maps.deptId} or find_in_set( #{maps.deptId} , ancestors ) ) ${maps.params.dataScope}")
     List<CompanyUser> getUserListByDeptId(@Param("maps") CompanyUser user);

+ 8 - 8
fs-service/src/main/java/com/fs/company/service/ICompanyUserRoleService.java

@@ -6,15 +6,15 @@ import java.util.List;
 
 /**
  * 用户和角色关联Service接口
- * 
+ *
  * @author fs
  * @date 2021-05-25
  */
-public interface ICompanyUserRoleService 
+public interface ICompanyUserRoleService
 {
     /**
      * 查询用户和角色关联
-     * 
+     *
      * @param userId 用户和角色关联ID
      * @return 用户和角色关联
      */
@@ -22,7 +22,7 @@ public interface ICompanyUserRoleService
 
     /**
      * 查询用户和角色关联列表
-     * 
+     *
      * @param companyUserRole 用户和角色关联
      * @return 用户和角色关联集合
      */
@@ -30,7 +30,7 @@ public interface ICompanyUserRoleService
 
     /**
      * 新增用户和角色关联
-     * 
+     *
      * @param companyUserRole 用户和角色关联
      * @return 结果
      */
@@ -38,7 +38,7 @@ public interface ICompanyUserRoleService
 
     /**
      * 修改用户和角色关联
-     * 
+     *
      * @param companyUserRole 用户和角色关联
      * @return 结果
      */
@@ -46,7 +46,7 @@ public interface ICompanyUserRoleService
 
     /**
      * 批量删除用户和角色关联
-     * 
+     *
      * @param userIds 需要删除的用户和角色关联ID
      * @return 结果
      */
@@ -54,7 +54,7 @@ public interface ICompanyUserRoleService
 
     /**
      * 删除用户和角色关联信息
-     * 
+     *
      * @param userId 用户和角色关联ID
      * @return 结果
      */

+ 1 - 0
fs-service/src/main/java/com/fs/course/service/IFsCourseLinkService.java

@@ -78,4 +78,5 @@ public interface IFsCourseLinkService
 
     R createRoomLinkUrl(FsCourseLinkCreateParam param);
 
+    R getRealLinkH5(String link);
 }

+ 1 - 1
fs-service/src/main/java/com/fs/course/service/IFsCourseQuestionBankService.java

@@ -64,7 +64,7 @@ public interface IFsCourseQuestionBankService
      */
     public int deleteFsCourseQuestionBankById(Long id);
 
-    R courseAnswer(FsCourseQuestionAnswerUParam param);
+    R courseAnswer(FsCourseQuestionAnswerUParam param,Boolean isH5User);
 
     /**
      * 题目导入

+ 53 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseLinkServiceImpl.java

@@ -506,4 +506,57 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
         }
         return R.error("短链生成失败!");
     }
+
+    @Override
+    public R getRealLinkH5(String link) {
+        try {
+            // URL解码
+            String sLink = URLDecoder.decode(link, "UTF-8");
+
+            // 从数据库中查找短链对应的真实链接
+            FsCourseLink courseLink = fsCourseLinkMapper.selectFsCourseLinkByLink(sLink);
+            if (courseLink != null) {
+                // 获取当前时间
+                Date currentTime = new Date();
+                // 获取链接的更新时间(假设这个字段代表过期时间)
+                Date updateTime = courseLink.getUpdateTime();
+
+                // 判断是否过期
+                if (currentTime.after(updateTime)) {
+                    // 链接已过期
+                    log.info("链接已过期: {}", sLink);
+                    return R.error("链接已过期").put("realLink", sLink);
+                } else {
+                    // 链接仍然有效,返回真实链接
+                    if (courseLink.getRealLink() == null) {
+                        log.error("真实链接不存在, link: {}", sLink);
+                        return R.error("真实链接不存在").put("realLink", sLink);
+                    }
+                    log.info("链接仍然有效: {}", sLink);
+                    String json = configService.selectConfigByKey("h5.course.config");
+                    CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+                    String domainName = companyUserMapper.selectDomainByUserId(courseLink.getCompanyUserId());
+                    if (StringUtils.isEmpty(domainName)){
+                        domainName = config.getRealLinkDomainName();
+                    }
+                    String realLink = domainName+courseLink.getRealLink();
+                    String imgUrl = "";
+                    return R.ok().put("realLink",realLink ).put("config",config).put("headerImg",imgUrl);
+                }
+            } else {
+                // 链接不存在或解析失败
+                log.warn("URL解析错误或链接不存在: {}", sLink);
+                return R.error("URL 解析错误或链接不存在").put("realLink", sLink);
+            }
+
+        } catch (UnsupportedEncodingException e) {
+            // URL解码异常
+            log.error("URL 解码失败: {}", e.getMessage(), e);
+            return R.error("URL 解码失败").put("realLink", link);
+        } catch (Exception e) {
+            // 捕获其他异常并记录
+            log.error("发生未知错误: {}", e.getMessage(), e);
+            return R.error("发生未知错误,请稍后再试").put("realLink", link);
+        }
+    }
 }

+ 7 - 2
fs-service/src/main/java/com/fs/course/service/impl/FsCourseQuestionBankServiceImpl.java

@@ -136,7 +136,7 @@ public class FsCourseQuestionBankServiceImpl implements IFsCourseQuestionBankSer
 
     @Override
     @Transactional
-    public R courseAnswer(FsCourseQuestionAnswerUParam param) {
+    public R courseAnswer(FsCourseQuestionAnswerUParam param,Boolean isH5User) {
         //获取配置参数
         String json = configService.selectConfigByKey("course.config");
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
@@ -159,7 +159,12 @@ public class FsCourseQuestionBankServiceImpl implements IFsCourseQuestionBankSer
             errorCount = courseAnswerLogsMapper.selectErrorCountByCourseVideo(param.getVideoId(), param.getUserId(),null);
 
         }else {
-            FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(),param.getVideoId(),param.getQwUserId(),param.getQwExternalId());
+            FsCourseWatchLog log;
+            if(isH5User){
+                log = courseWatchLogMapper.getWatchLogByFsUser(param.getVideoId(), param.getUserId(), param.getCompanyUserId());
+            } else {
+                log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId());
+            }
             if (log==null){
                 return R.error("无记录");
             }

+ 68 - 0
fs-service/src/main/resources/mapper/company/CompanyUserMapper.xml

@@ -329,4 +329,72 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </update>
+
+
+    <select id="selectMyUserList" parameterType="com.fs.company.vo.CompanyUserVO" resultMap="CompanyUserVOResult">
+        select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.open_id,u.id_card, d.dept_name, d.leader, u.is_audit,
+        cr.role_id, cr.role_name
+        from company_user u
+        left join company_user_role cur on cur.user_id = u.user_id
+        left join company_role cr on cr.role_id = cur.role_id
+        left join company_dept d on u.dept_id = d.dept_id
+        where u.del_flag = '0' and u.status=0
+        <if test="companyId != null  ">
+            AND u.company_id = #{companyId}
+        </if>
+        <if test="nickName != null and nickName != ''">
+            AND u.nick_name like concat('%', #{nickName}, '%')
+        </if>
+        <if test="phonenumber != null and phonenumber != ''">
+            AND u.phonenumber like concat('%', #{phonenumber}, '%')
+        </if>
+        <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
+            AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
+        </if>
+        <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
+            AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
+        </if>
+        <if test="deptId != null and deptId != 0">
+            AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{deptId}, ancestors) ))
+        </if>
+        <if test="isAudit != null">
+            AND u.is_audit = #{isAudit}
+        </if>
+
+    </select>
+
+    <resultMap type="com.fs.company.vo.CompanyUserVO" id="CompanyUserVOResult">
+        <result property="userId"    column="user_id"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="deptId"    column="dept_id"    />
+        <result property="userName"    column="user_name"    />
+        <result property="nickName"    column="nick_name"    />
+        <result property="userType"    column="user_type"    />
+        <result property="email"    column="email"    />
+        <result property="phonenumber"    column="phonenumber"    />
+        <result property="sex"    column="sex"    />
+        <result property="avatar"    column="avatar"    />
+        <result property="idCard"    column="id_card"    />
+        <result property="password"    column="password"    />
+        <result property="status"    column="status"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="loginIp"    column="login_ip"    />
+        <result property="loginDate"    column="login_date"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="token"    column="token"    />
+        <result property="remark"    column="remark"    />
+        <result property="openId"    column="open_id"    />
+        <result property="nowDayCustomerCount"    column="now_day_customer_count"    />
+        <result property="domain"    column="domain"    />
+        <result property="isAudit"    column="is_audit"    />
+        <result property="addressId"    column="address_id"    />
+        <association property="dept"    column="dept_id" javaType="CompanyDept" resultMap="deptResult" />
+        <collection  property="roles"   javaType="java.util.List"        resultMap="RoleResult" />
+        <collection property="posts" javaType="java.util.ArrayList" ofType="com.fs.company.domain.CompanyPost"
+                    select="com.fs.company.mapper.CompanyPostMapper.selectPostsByUserId" column="{user_id=user_id}" />
+
+    </resultMap>
 </mapper>

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

@@ -433,7 +433,7 @@ public class CourseController extends  AppBaseController{
             logger.info("zyp \n【未识别到时长】:{}",param.getUserId());
         }
         param.setUserId(Long.parseLong(getUserId()));
-        return questionBankService.courseAnswer(param);
+        return questionBankService.courseAnswer(param,false);
     }
 
 

+ 132 - 0
fs-user-app/src/main/java/com/fs/app/controller/CourseWxH5Controller.java

@@ -0,0 +1,132 @@
+package com.fs.app.controller;
+
+
+import com.fs.app.annotation.Login;
+import com.fs.common.annotation.RepeatSubmit;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.ResponseResult;
+import com.fs.course.param.FsCourseQuestionAnswerUParam;
+import com.fs.course.param.FsCourseSendRewardUParam;
+import com.fs.course.param.FsUserCourseVideoFinishUParam;
+import com.fs.course.param.newfs.FsUserCourseAddCompanyUserParam;
+import com.fs.course.param.newfs.FsUserCourseVideoLinkParam;
+import com.fs.course.param.newfs.FsUserCourseVideoUParam;
+import com.fs.course.service.*;
+import com.fs.course.vo.FsUserCourseVideoH5VO;
+import com.fs.course.vo.newfs.FsUserCourseVideoLinkDetailsVO;
+import com.fs.his.service.IFsUserService;
+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.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+@Api("会员-h5看课接口")
+@RestController
+@RequestMapping(value = "/app/course/wx/h5")
+public class CourseWxH5Controller extends AppBaseController {
+    Logger logger = LoggerFactory.getLogger(getClass());
+    @Autowired
+    private IFsUserCourseService courseService;
+
+    @Autowired
+    private IFsUserCourseVideoService courseVideoService;
+
+    @Autowired
+    private ISysConfigService configService;
+
+    @Autowired
+    private IFsCourseLinkService courseLinkService;
+
+    @Autowired
+    private IFsCourseWatchLogService courseWatchLogService;
+
+    @Autowired
+    private IFsCourseQuestionBankService questionBankService;
+
+    @Autowired
+    private IFsUserService fsUserService;
+
+
+    @Login
+    @ApiOperation("判断是否添加客服(是否关联销售)")
+    @PostMapping("/isAddKf")
+    public ResponseResult<Boolean> isAddCompanyUser(@Valid @RequestBody FsUserCourseAddCompanyUserParam param) {
+        Long userId = Long.parseLong(getUserId());
+        param.setUserId(userId);
+        return courseVideoService.isAddCompanyUser(param);
+    }
+
+    @ApiOperation("h5课程简介")
+    @GetMapping("/getH5CourseByVideoId")
+    public R getCourseByVideoId(@RequestParam("videoId") Long videoId)
+    {
+        FsUserCourseVideoH5VO course = courseService.selectFsUserCourseVideoH5VOByVideoId(videoId);
+        return R.ok().put("data",course);
+    }
+
+    @Login
+    @ApiOperation("H5课程详情")
+    @GetMapping("/videoDetails")
+    public ResponseResult<FsUserCourseVideoLinkDetailsVO> getCourseVideoDetails(FsUserCourseVideoLinkParam param) {
+        param.setFsUserId(Long.parseLong(getUserId()));
+        return courseVideoService.getLinkCourseVideoDetails(param);
+    }
+
+    @ApiOperation("获取真实链接")
+    @GetMapping("/getRealLink")
+    public R getRealLink(@RequestParam("sortLink")String link)
+    {
+        return courseLinkService.getRealLinkH5(link);
+    }
+
+    @ApiOperation("更新看课时长")
+    @PostMapping("/updateWatchDuration")
+    public R updateWatchDuration(@RequestBody FsUserCourseVideoUParam param)
+    {
+        param.setUserId(Long.parseLong(getUserId()));
+        return courseVideoService.updateWatchDurationWx(param);
+    }
+
+
+    @ApiOperation("获取缓冲流量")
+    @PostMapping("/getInternetTraffic")
+    public R getInternetTraffic(@RequestBody FsUserCourseVideoFinishUParam param) {
+        param.setUserId(Long.parseLong(getUserId()));
+        return courseVideoService.getInternetTraffic(param);
+    }
+
+
+    @ApiOperation("答题")
+    @PostMapping("/courseAnswer")
+    public R courseAnswer(@RequestBody FsCourseQuestionAnswerUParam param){
+        param.setUserId(Long.parseLong(getUserId()));
+        logger.info("zyp \n【答题】:{}",param.getQuestions());
+        if (param.getDuration()==null){
+            logger.info("zyp \n【未识别到时长】:{}",param.getUserId());
+        }
+        return questionBankService.courseAnswer(param, true);
+    }
+
+    @ApiOperation("发放奖励")
+    @PostMapping("/sendReward")
+    @RepeatSubmit
+    public R sendReward(@RequestBody FsCourseSendRewardUParam param)
+    {
+        param.setUserId(Long.parseLong(getUserId()));
+        logger.info("zyp \n【发放奖励】:{}",param);
+        return courseVideoService.sendRewardByFsUser(param);
+    }
+
+
+    @PostMapping("/getErrMsg")
+    public void getErrMsg(@RequestParam("msg") String msg) {
+        logger.error("zyp \n【h5看课中途报错】:{}",msg);
+    }
+
+
+}