wangxy 1 nedēļu atpakaļ
vecāks
revīzija
e817da00d5

+ 1 - 0
fs-admin/src/main/java/com/fs/course/controller/FsVideoResourceController.java

@@ -78,6 +78,7 @@ public class FsVideoResourceController extends BaseController {
         }
         PageHelper.startPage(pageNum, pageSize);
         List<FsVideoResourceVO> list = fsVideoResourceService.selectVideoResourceListByMap(params);
+        list = list.stream().peek(FsVideoResourceVO::formatFileSize).collect(Collectors.toList());
         return getDataTable(list);
     }
 

+ 16 - 0
fs-admin/src/main/java/com/fs/his/controller/FsUserController.java

@@ -11,6 +11,7 @@ import com.fs.common.core.domain.entity.SysUser;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.course.service.IFsCourseWatchLogService;
 import com.fs.course.service.IFsUserCompanyUserService;
 import com.fs.his.domain.FsUserAddress;
 import com.fs.his.domain.FsUserCompanyUserTransferTask;
@@ -79,6 +80,8 @@ public class FsUserController extends BaseController
 
     @Autowired
     private SqlSessionFactory sqlSessionFactory;
+    @Autowired
+    private IFsCourseWatchLogService fsCourseWatchLogService;
 
     /**
      * 查询用户列表
@@ -497,4 +500,17 @@ public class FsUserController extends BaseController
         return util.exportExcel(list,"会员转移失败数据");
     }
 
+    /**
+     * 清除用户当天的看课记录
+     */
+    @ApiOperation("清除用户当天的看课记录")
+    @PreAuthorize("@ss.hasPermi('his:user:clearUserWatchRecord')")
+    @PostMapping("/clearUserWatchRecord")
+    public R clearUserWatchRecord(@RequestBody FsUserAddPointsParam param) {
+       if (param.getProjectId() == null) {
+           return R.error("项目ID不能为空");
+       }
+        return fsCourseWatchLogService.clearUserWatchLog(param.getUserId(), param.getProjectId());
+    }
+
 }

+ 13 - 0
fs-admin/src/main/java/com/fs/transfer/CustomerTransferApprovalController.java

@@ -13,6 +13,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 客户转移审批Controller
@@ -62,6 +63,18 @@ public class CustomerTransferApprovalController extends BaseController
         return AjaxResult.success(customerTransferApprovalService.selectCustomerTransferApprovalById(id));
     }
 
+
+    /**
+     * 根据ID获取客户转移审批相关用户ID列表
+     */
+
+    @PostMapping(value = "/getUserIdsByApprovalIds")
+    public AjaxResult getUserIdsByApprovalIds(@RequestBody  Long[] ids)
+    {
+        Map<Long, List<Long>> longListMap = customerTransferApprovalService.selectCustomerTransferApprovalListByCustomerId(ids);
+        return AjaxResult.success(longListMap);
+    }
+
     /**
      * 新增客户转移审批
      */

+ 9 - 0
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -13,6 +13,7 @@ import com.fs.qw.domain.QwExternalContact;
 import com.fs.qw.param.QwSidebarStatsParam;
 import com.fs.sop.vo.QwRatingVO;
 import com.fs.statis.dto.WatchCourseStatisticsResultDTO;
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -811,4 +812,12 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
      */
     @Select("select count(log_id) from fs_course_watch_log where user_id = #{userId} and project = #{projectId}")
     Long getCountByUserIdAndProjectId(@Param("userId") Long userId, @Param("projectId") Long projectId);
+
+    /**
+     * 查询用户当天的看课记录
+     * @param userId
+     * @param projectId
+     */
+     @Select("select * from fs_course_watch_log where user_id = #{userId} and project = #{projectId} and create_time >= #{startTime}")
+     FsCourseWatchLog selectByUserIdAndProjectId(@Param("userId") Long userId, @Param("projectId") Long projectId, @Param("startTime") Date startTime);
 }

+ 8 - 0
fs-service/src/main/java/com/fs/course/service/IFsCourseWatchLogService.java

@@ -1,6 +1,7 @@
 package com.fs.course.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.common.core.domain.R;
 import com.fs.course.domain.FsCourseWatchLog;
 import com.fs.course.param.*;
 import com.fs.course.vo.*;
@@ -170,4 +171,11 @@ public interface IFsCourseWatchLogService extends IService<FsCourseWatchLog> {
      * @return
      */
     List<Long> getExContactIdsIdsByWatchLogIds(List<Long> watchLogIds);
+
+    /**
+     * 清除用户当天的看课记录
+     * @param userId
+     * @param projectId
+     */
+    R clearUserWatchLog(Long userId, Long projectId);
 }

+ 16 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.DictUtils;
@@ -1857,5 +1858,20 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
         return fsCourseWatchLogMapper.getExContactIdsIdsByWatchLogIds(watchLogIds);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R clearUserWatchLog(Long userId, Long projectId) {
+        Date startTime = removeTime(new Date());
+        FsCourseWatchLog fsCourseWatchLog = fsCourseWatchLogMapper.selectByUserIdAndProjectId(userId, projectId, startTime);
+        if (fsCourseWatchLog != null) {
+            int i = fsCourseWatchLogMapper.deleteById(fsCourseWatchLog.getLogId());
+            if (i < 0) {
+                return R.error("清除失败");
+            }
+        }else {
+            return R.error("没有需要清除的记录");
+        }
+        return R.ok("清除成功");
+    }
 
 }

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

@@ -1466,6 +1466,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
      */
     private R sendRedPacketReward(FsCourseSendRewardUParam param, FsUser user, FsCourseWatchLog log, FsUserCourseVideo video, CourseConfig config) {
         logger.info("进入发放红包");
+        //销售账号是否禁用
+        CompanyUser companyUser = companyUserMapper.getInviteCodeByCompanyUserIdAndUserId(param.getCompanyUserId());
+        if (companyUser == null || "1".equals(companyUser.getStatus())) {
+            return R.error("客服开小差了,红包发送失败!请联系群主。");
+        }
         // 确定红包金额
         BigDecimal amount = BigDecimal.ZERO;
         //获取公司课程的红包金额
@@ -1640,7 +1645,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
         if (periodDays != null && periodDays.getLastJoinTime() != null && LocalDateTime.now().isAfter(periodDays.getLastJoinTime())) {
             return R.error(403, "已超过领取红包时间");
         }
-
+        //销售账号是否禁用
+        CompanyUser companyUser = companyUserMapper.getInviteCodeByCompanyUserIdAndUserId(param.getCompanyUserId());
+        if (companyUser == null || "1".equals(companyUser.getStatus())) {
+            return R.error("客服开小差了,红包发送失败!请联系群主。");
+        }
 
         // 确定红包金额
         BigDecimal amount = BigDecimal.ZERO;

+ 11 - 0
fs-service/src/main/java/com/fs/course/vo/FsVideoResourceVO.java

@@ -66,6 +66,8 @@ public class FsVideoResourceVO {
      */
     private Long fileSize;
 
+    private String formattedFileSize;
+
     /**
      * 文件key
      */
@@ -87,4 +89,13 @@ public class FsVideoResourceVO {
     private String projectIds;
 
     private Integer sort;
+
+    public void formatFileSize() {
+        if (this.fileSize == null) {
+            this.formattedFileSize = "0.0000 MB";
+        } else {
+            double gb = this.fileSize.doubleValue() / (1024 * 1024 * 1024);
+            this.formattedFileSize = String.format("%.4f GB", gb);
+        }
+    }
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/param/FsUserAddPointsParam.java

@@ -16,4 +16,6 @@ public class FsUserAddPointsParam {
     private Integer point;
 
     private String remark;
+
+    private Long projectId;
 }

+ 2 - 0
fs-service/src/main/java/com/fs/qw/mapper/CustomerTransferApprovalMapper.java

@@ -20,6 +20,8 @@ public interface CustomerTransferApprovalMapper
      */
     public CustomerTransferApproval selectCustomerTransferApprovalById(Long id);
 
+    public List<CustomerTransferApproval> selectCustomerTransferApprovalByIds(Long[] ids);
+
     /**
      * 查询客户转移审批列表
      *

+ 3 - 0
fs-service/src/main/java/com/fs/qw/service/ICustomerTransferApprovalService.java

@@ -3,6 +3,7 @@ package com.fs.qw.service;
 import com.fs.qw.domain.CustomerTransferApproval;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 客户转移审批Service接口
@@ -20,6 +21,8 @@ public interface ICustomerTransferApprovalService
      */
     public CustomerTransferApproval selectCustomerTransferApprovalById(Long id);
 
+    public Map<Long, List<Long>> selectCustomerTransferApprovalListByCustomerId(Long[] ids);
+
     /**
      * 查询客户转移审批列表
      *

+ 45 - 0
fs-service/src/main/java/com/fs/qw/service/impl/CustomerTransferApprovalServiceImpl.java

@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 客户转移审批Service业务层处理
@@ -127,6 +128,50 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp
         return item;
     }
 
+    @Override
+    public Map<Long, List<Long>> selectCustomerTransferApprovalListByCustomerId(Long[] ids) {
+        List<CustomerTransferApproval> customerTransferApprovals = customerTransferApprovalMapper.selectCustomerTransferApprovalByIds(ids);
+        Map<Long, List<Long>> groupedUserIds = new HashMap<>();
+
+        for (CustomerTransferApproval approval : customerTransferApprovals) {
+            // 从 transferBefore 中解析 beforeCompanyUserId 列表
+            Set<Long> beforeCompanyUserIds = new HashSet<>(); // 使用Set去重
+            if (StringUtils.isNotEmpty(approval.getTransferBefore())) {
+                List<TransferCustomDTO> transferBeforeList = JSON.parseArray(approval.getTransferBefore(), TransferCustomDTO.class);
+                for (TransferCustomDTO transferData : transferBeforeList) {
+                    if (transferData != null && transferData.getBeforeCompanyUserId() != null) {
+                        beforeCompanyUserIds.add(transferData.getBeforeCompanyUserId());
+                    }
+                }
+            }
+
+            // 从 customerIds 中解析 userId 列表
+            List<Long> userIds = new ArrayList<>();
+            if (StringUtils.isNotEmpty(approval.getCustomerIds())) {
+                List<UserProjectDTO> customerIds = JSON.parseArray(approval.getCustomerIds(), UserProjectDTO.class);
+                for (UserProjectDTO customer : customerIds) {
+                    if (customer != null && customer.getUserId() != null) {
+                        userIds.add(customer.getUserId());
+                    }
+                }
+            }
+
+            // 将 userIds 按照 beforeCompanyUserIds 进行分组,避免覆盖
+            for (Long beforeCompanyUserId : beforeCompanyUserIds) {
+                groupedUserIds.computeIfAbsent(beforeCompanyUserId, k -> new ArrayList<>())
+                        .addAll(userIds);
+            }
+        }
+
+        // 对每个分组中的 userId 进行去重
+        for (Map.Entry<Long, List<Long>> entry : groupedUserIds.entrySet()) {
+            List<Long> uniqueUserIds = entry.getValue().stream().distinct().collect(Collectors.toList());
+            entry.setValue(uniqueUserIds);
+        }
+
+        return groupedUserIds;
+    }
+
     private List<TransferCustomDTO> getCustomerList(List<UserProjectDTO> customerIds, CustomerTransferApproval item) {
         if (CollectionUtils.isEmpty(customerIds) || item == null) {
             return new ArrayList<>();

+ 7 - 0
fs-service/src/main/resources/mapper/qw/CustomerTransferApprovalMapper.xml

@@ -54,6 +54,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="queryPendingData" resultType="com.fs.qw.domain.CustomerTransferApproval">
         select * from customer_transfer_approval where approval_status=0
     </select>
+    <select id="selectCustomerTransferApprovalByIds" resultType="com.fs.qw.domain.CustomerTransferApproval">
+        <include refid="selectCustomerTransferApprovalVo"/>
+        where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </select>
 
     <insert id="insertCustomerTransferApproval" parameterType="CustomerTransferApproval" useGeneratedKeys="true" keyProperty="id">
         insert into customer_transfer_approval