Parcourir la source

Merge branch 'Payment-Configuration_refund' into Payment

# Conflicts:
#	fs-live-app/src/main/java/com/fs/live/task/Task.java
#	fs-service/src/main/java/com/fs/his/enums/FsUserIntegralLogTypeEnum.java
#	fs-service/src/main/java/com/fs/huifuPay/service/impl/HuiFuServiceImpl.java
#	fs-user-app/src/main/java/com/fs/app/controller/live/LiveCompletionPointsController.java
yfh il y a 9 heures
Parent
commit
149122811a
35 fichiers modifiés avec 317 ajouts et 192 suppressions
  1. 15 0
      fs-admin/src/main/java/com/fs/his/task/CompanyBalanceTask.java
  2. 3 0
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java
  3. 2 2
      fs-admin/src/main/resources/application.yml
  4. 4 4
      fs-company-app/src/main/java/com/fs/app/controller/FsUserController.java
  5. 0 1
      fs-company-app/src/main/java/com/fs/app/controller/FsUserCourseVideoController.java
  6. 1 1
      fs-company-app/src/main/java/com/fs/app/controller/WxCompanyUserController.java
  7. 11 0
      fs-company/src/main/java/com/fs/company/controller/common/CommonController.java
  8. 18 17
      fs-live-app/src/main/java/com/fs/live/task/Task.java
  9. 1 1
      fs-quartz/src/main/java/com/fs/quartz/config/ScheduleConfig.java
  10. 2 0
      fs-service/src/main/java/com/fs/company/service/ICompanyService.java
  11. 92 29
      fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java
  12. 1 1
      fs-service/src/main/java/com/fs/course/mapper/FsCourseAnswerLogsMapper.java
  13. 12 3
      fs-service/src/main/java/com/fs/course/service/impl/FsCourseProductOrderServiceImpl.java
  14. 4 0
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseOrderServiceImpl.java
  15. 9 3
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseServiceImpl.java
  16. 4 0
      fs-service/src/main/java/com/fs/course/service/impl/FsUserVipOrderServiceImpl.java
  17. 9 0
      fs-service/src/main/java/com/fs/his/domain/FsStorePayment.java
  18. 12 4
      fs-service/src/main/java/com/fs/his/service/impl/FsInquiryOrderServiceImpl.java
  19. 9 1
      fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java
  20. 6 2
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java
  21. 4 3
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java
  22. 3 2
      fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java
  23. 3 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsStorePaymentScrm.java
  24. 2 4
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java
  25. 10 8
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
  26. 2 9
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java
  27. 24 17
      fs-service/src/main/java/com/fs/huifuPay/sdk/opps/core/utils/HuiFuUtils.java
  28. 6 42
      fs-service/src/main/java/com/fs/huifuPay/service/impl/HuiFuServiceImpl.java
  29. 2 2
      fs-service/src/main/resources/application-config-druid-sft.yml
  30. 1 1
      fs-service/src/main/resources/mapper/company/CompanyRedPacketBalanceLogsMapper.xml
  31. 9 1
      fs-service/src/main/resources/mapper/course/FsCourseAnswerLogsMapper.xml
  32. 2 0
      fs-service/src/main/resources/mapper/his/FsStorePaymentMapper.xml
  33. 1 1
      fs-user-app/src/main/java/com/fs/app/controller/WxH5MpController.java
  34. 1 1
      fs-user-app/src/main/java/com/fs/app/controller/course/CourseFsUserLoginController.java
  35. 32 32
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveCompletionPointsController.java

+ 15 - 0
fs-admin/src/main/java/com/fs/his/task/CompanyBalanceTask.java

@@ -1,5 +1,6 @@
 package com.fs.his.task;
 
+import com.fs.common.core.domain.R;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.company.service.ICompanyService;
@@ -114,6 +115,20 @@ public class CompanyBalanceTask {
 
 
 
+    /**
+     * @Description: 更具批次号查询转账结果
+     * @Param:
+     * @Return:
+     * @Author xgb
+     * @Date 2025/12/25 10:31
+     */
+    public void checkMchTransferStatusByBatchID(String batchId,String companyIdStr) {
+        Long companyId=Long.parseLong(companyIdStr);
+        R result=companyService.checkMchTransferStatusByBatchID(batchId,companyId);
+        log.info("查询商户转账结果:{}",result);
+    }
+
+
 
 
 }

+ 3 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -1,6 +1,7 @@
 package com.fs.hisStore.controller;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -206,6 +207,8 @@ public class FsStoreOrderScrmController extends BaseController {
             for (FsStoreOrderVO vo : list) {
                 if(vo.getPhone()!=null){
                     vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+                }
+                if(ObjectUtil.isNotEmpty(vo.getUserPhone())){
                     vo.setUserPhone(vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
                 }
                 if (CloudHostUtils.hasCloudHostName("康年堂")){

+ 2 - 2
fs-admin/src/main/resources/application.yml

@@ -4,11 +4,11 @@ server:
 # Spring配置
 spring:
   profiles:
-    active: dev-test
+#    active: dev-test
 #    active: druid-hdt
 #    active: druid-yzt
 #    active: druid-sxjz-test
 #    active: druid-sft
 #    active: druid-fby
-#    active: dev
+    active: dev
 

+ 4 - 4
fs-company-app/src/main/java/com/fs/app/controller/FsUserController.java

@@ -214,8 +214,8 @@ public class FsUserController extends AppBaseController {
     ) {
         long userId = Long.parseLong(getUserId());
         // 中康的数据太多太卡不要这个
-//        return ResponseResult.ok(Collections.emptyList());
-        return ResponseResult.ok(fsUserService.userRanking(userId, startTime, endTime, periodId, videoId, order, type));
+        return ResponseResult.ok(Collections.emptyList());
+//        return ResponseResult.ok(fsUserService.userRanking(userId, startTime, endTime, periodId, videoId, order, type));
     }
 
     @Login
@@ -231,8 +231,8 @@ public class FsUserController extends AppBaseController {
     ) {
         long userId = Long.parseLong(getUserId());
         // 中康的数据太多太卡不要这个
-//        return ResponseResult.ok(Collections.emptyList());
-        return ResponseResult.ok(fsUserService.courseRanking(userId, startTime, endTime, courseId, videoId, order, type));
+        return ResponseResult.ok(Collections.emptyList());
+//        return ResponseResult.ok(fsUserService.courseRanking(userId, startTime, endTime, courseId, videoId, order, type));
     }
 
     @Login

+ 0 - 1
fs-company-app/src/main/java/com/fs/app/controller/FsUserCourseVideoController.java

@@ -170,7 +170,6 @@ public class FsUserCourseVideoController extends AppBaseController {
         } else {
             params.put("companyUserId", companyUser.getUserId());
         }
-
         PageHelper.startPage(pageNum, pageSize);
         List<FsUserCourseParticipationRecordVO> record = fsUserCourseService.getParticipationRecordByMap(params);
         return ResponseResult.ok(new PageInfo<>(record));

+ 1 - 1
fs-company-app/src/main/java/com/fs/app/controller/WxCompanyUserController.java

@@ -171,7 +171,7 @@ public class WxCompanyUserController extends AppBaseController {
      */
     private FsUser createUser(LoginMaWxParam param, WxMaJscode2SessionResult session, WxMaPhoneNumberInfo phoneNoInfo, Company company, CompanyUser companyUser) {
         FsUser user = new FsUser();
-        user.setStatus((company != null ? company.getFsUserIsDefaultBlack() : 0) == 1 ? 0 : 1);
+        user.setStatus(1);
         user.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
         user.setCreateTime(new Date());
         if (param.getAuthType() == 1 && phoneNoInfo != null) {

+ 11 - 0
fs-company/src/main/java/com/fs/company/controller/common/CommonController.java

@@ -120,6 +120,17 @@ public class CommonController
         return R.ok();
     }
 
+    @GetMapping("common/test3")
+    public R test2(String companyIdStr,String outBatchNo) throws Exception
+    {
+        // 默认是前两天时间
+        Long companyId=Long.parseLong(companyIdStr);
+        R result=companyService.checkMchTransferStatusByBatchID(outBatchNo,companyId);
+        log.info("查询商户转账结果:{}",result);
+        return R.ok();
+    }
+
+
     /**
      * 通用下载请求
      *

+ 18 - 17
fs-live-app/src/main/java/com/fs/live/task/Task.java

@@ -186,17 +186,17 @@ public class Task {
                                 .mapToLong(LiveVideo::getDuration)
                                 .sum();
                     }
-                    
+
                     // 如果视频时长大于0,将直播间信息存入Redis
                     if (videoDuration > 0 && live.getStartTime() != null) {
                         Map<String, Object> tagMarkInfo = new HashMap<>();
                         tagMarkInfo.put("liveId", live.getLiveId());
                         tagMarkInfo.put("startTime", live.getStartTime().atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli());
                         tagMarkInfo.put("videoDuration", videoDuration);
-                        
+
                         String tagMarkKey = String.format(LiveKeysConstant.LIVE_TAG_MARK_CACHE, live.getLiveId());
                         redisCache.setCacheObject(tagMarkKey, JSON.toJSONString(tagMarkInfo), 24, TimeUnit.HOURS);
-                        log.info("直播间开启,已加入打标签缓存: liveId={}, startTime={}, videoDuration={}", 
+                        log.info("直播间开启,已加入打标签缓存: liveId={}, startTime={}, videoDuration={}",
                                 live.getLiveId(), live.getStartTime(), videoDuration);
                     }
                 } catch (Exception e) {
@@ -537,19 +537,19 @@ public class Task {
                 // 回放:使用 Redis 中的数据减去直播的数据,得到回放的数据
                 String likeKey = "live:like:" + liveData.getLiveId();
                 String totalViewsKey = TOTAL_VIEWS_KEY + liveData.getLiveId();
-                
+
                 // 从 Redis 获取总数据(直播+回放)
                 Long totalLikeCount = getAsLong(redisCache, likeKey);
                 Long totalViewCount = getAsLong(redisCache, totalViewsKey);
-                
+
                 // 获取数据库中直播的数据
                 Long liveLikeCount = liveData.getLikes() != null ? liveData.getLikes() : 0L;
                 Long liveViewCount = liveData.getTotalViews() != null ? liveData.getTotalViews() : 0L;
-                
+
                 // 回放数据 = Redis总数据 - 直播数据
                 Long replayLikeNum = totalLikeCount - liveLikeCount;
                 Long replayViewNum = totalViewCount - liveViewCount;
-                
+
                 // 确保回放数据不为负数
                 if (replayLikeNum < 0L) {
                     replayLikeNum = 0L;
@@ -557,7 +557,7 @@ public class Task {
                 if (replayViewNum < 0L) {
                     replayViewNum = 0L;
                 }
-                
+
                 // 更新回放数据
                 liveData.setReplayLikeNum(replayLikeNum);
                 liveData.setReplayViewNum(replayViewNum);
@@ -646,11 +646,11 @@ public class Task {
             // 获取所有打标签缓存的key
             String pattern = String.format(LiveKeysConstant.LIVE_TAG_MARK_CACHE, "*");
             Set<String> keys = redisCache.redisTemplate.keys(pattern);
-            
+
             if (keys == null || keys.isEmpty()) {
                 return;
             }
-            
+
             long currentTimeMillis = System.currentTimeMillis();
             LocalDateTime now = LocalDateTime.now();
             List<Long> processedLiveIds = new ArrayList<>();
@@ -662,19 +662,19 @@ public class Task {
                     if (cacheValue == null) {
                         continue;
                     }
-                    
+
                     String jsonStr = cacheValue.toString();
                     JSONObject tagMarkInfo = JSON.parseObject(jsonStr);
                     Long liveId = tagMarkInfo.getLong("liveId");
                     Long startTimeMillis = tagMarkInfo.getLong("startTime");
                     Long videoDuration = tagMarkInfo.getLong("videoDuration");
-                    
+
                     if (liveId == null || startTimeMillis == null || videoDuration == null || videoDuration <= 0) {
-                        log.warn("直播间打标签缓存信息不完整: key={}, liveId={}, startTime={}, videoDuration={}", 
+                        log.warn("直播间打标签缓存信息不完整: key={}, liveId={}, startTime={}, videoDuration={}",
                                 key, liveId, startTimeMillis, videoDuration);
                         continue;
                     }
-                    
+
                     // 查询直播间信息
                     Live live = liveService.selectLiveDbByLiveId(liveId);
                     if (live == null || live.getStartTime() == null) {
@@ -791,7 +791,7 @@ public class Task {
                     log.error("处理直播间打标签缓存异常: key={}, error={}", key, e.getMessage(), e);
                 }
             }
-            
+
             // 删除已处理的直播间缓存
             for (Long liveId : processedLiveIds) {
                 try {
@@ -871,6 +871,7 @@ public class Task {
                             if (onlineSeconds == null || onlineSeconds <= 0) {
                                 continue;
                             }
+
                             // 获取用户的 companyId 和 companyUserId
                             LiveUserFirstEntry liveUserFirstEntry =
                                     liveUserFirstEntryService.selectEntityByLiveIdUserIdWithCache(liveId, userId);
@@ -891,7 +892,7 @@ public class Task {
                             // 使用 updateLiveWatchLogTypeByDuration 的逻辑更新观看记录状态
                             updateLiveWatchLogTypeByDuration(liveId, userId, qwUserId, externalContactId,
                                     onlineSeconds, totalVideoDuration, updateLog);
-                            
+
                         } catch (Exception e) {
                             log.error("处理用户观看记录状态异常: liveId={}, userId={}, error={}",
                                     liveId, user.getUserId(), e.getMessage(), e);
@@ -909,7 +910,7 @@ public class Task {
                             redisCache.setCacheObject("live:watch:log:cache:" + liveWatchLog.getLogId(), liveWatchLog, 1, TimeUnit.HOURS);
                         }
                     }
-                    
+
                 } catch (Exception e) {
                     log.error("处理直播间观看记录状态异常: liveId={}, error={}",
                             live.getLiveId(), e.getMessage(), e);

+ 1 - 1
fs-quartz/src/main/java/com/fs/quartz/config/ScheduleConfig.java

@@ -49,7 +49,7 @@ public class ScheduleConfig
         // 可选,QuartzScheduler
         // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
         factory.setOverwriteExistingJobs(true);
-        // 设置自动启动,默认为true
+        // 设置自动启动,默认为true 切记调整为true
         factory.setAutoStartup(true);
 //        factory.setAutoStartup(false);
 

+ 2 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyService.java

@@ -200,4 +200,6 @@ public interface ICompanyService
     void subLiveCompanyMoney(LiveOrder order);
 
     String checkMchTransferStatus(String outBatchNo,Long companyId);
+
+    R checkMchTransferStatusByBatchID(String batchId, Long companyId);
 }

+ 92 - 29
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -272,6 +272,76 @@ public class CompanyServiceImpl implements ICompanyService
         throw new CustomException("转账处理中");
     }
 
+    @Override
+    public R checkMchTransferStatusByBatchID(String batchId, Long companyId) {
+        // 获取配置信息
+        CourseConfig courseConfig = JSONUtil.toBean(configService.selectConfigByKey("course.config"), CourseConfig.class);
+
+        String json;
+        RedPacketConfig config = new RedPacketConfig();
+        // 根据红包模式获取配置
+        switch (courseConfig.getRedPacketMode()){
+            case 1:
+                json = configService.selectConfigByKey("redPacket.config");
+                config = JSONUtil.toBean(json, RedPacketConfig.class);
+                break;
+            case 2:
+                json = companyConfigService.selectRedPacketConfigByKey(companyId);
+                //如果分公司配置为空就走总后台的配置
+                if (StringUtils.isEmpty(json)){
+                    json = configService.selectConfigByKey("redPacket.config");
+                }
+                config = JSONUtil.toBean(json, RedPacketConfig.class);
+                break;
+            default:
+                throw new UnsupportedOperationException("当前红包模式不支持!");
+        }
+
+        //创建微信订单
+        WxPayConfig payConfig = new WxPayConfig();
+        BeanUtils.copyProperties(config,payConfig);
+        WxPayService wxPayService = new WxPayServiceImpl();
+        wxPayService.setConfig(payConfig);
+        TransferService transferService=wxPayService.getTransferService();
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("status","待确认"); //
+        if (config.getIsNew() != null && config.getIsNew() == 1) {
+            try {
+                TransferBillsGetResult queryRedPacketResult = transferService.getBillsByTransferBillNo(batchId);
+                logger.info("FsCourseRedPacketLog-batchId:{},【红包处理】查询批次结果:{}",batchId,queryRedPacketResult.toString());
+                if(("SUCCESS").equals(queryRedPacketResult.getState())){
+                    map.put("status","success");
+                }else if(("FAIL").equals(queryRedPacketResult.getState())){
+                    map.put("status","fail");
+                }
+                return R.ok(map);
+            } catch (WxPayException e) {
+                logger.error(e.getMessage());
+                return R.error(e.getMessage());
+            }
+        } else {
+            QueryTransferBatchesRequest request = new QueryTransferBatchesRequest();
+            request.setBatchId(batchId);
+            request.setNeedQueryDetail(false);
+
+            try {
+                QueryTransferBatchesResult queryTransferBatchesResult = transferService.transferBatchesBatchId(request);
+                logger.info("FsCourseRedPacketLog-batchId,【红包处理】查询批次结果:{}",batchId,queryTransferBatchesResult.toString());
+                if(("FINISHED").equals(queryTransferBatchesResult.getTransferBatch().getBatchStatus())){
+                    map.put("status","success");
+                }else if(("CLOSED").equals(queryTransferBatchesResult.getTransferBatch().getBatchStatus())){
+                    map.put("status","fail");
+                }
+                return R.ok(map);
+            } catch (WxPayException e) {
+                logger.error(e.getMessage());
+                return R.error(e.getMessage());
+            }
+        }
+
+    }
+
     @Override
     public List<OptionsVO> selectAllCompanyList(Long deptId) {
         return companyMapper.selectAllCompanyList(deptId);
@@ -1749,10 +1819,6 @@ public class CompanyServiceImpl implements ICompanyService
         // 回滚前查询一下红包记录
         List<CompanyRedPacketBalanceLogs> companyRedPacketBalanceLogsList = companyRedPacketBalanceLogsMapper.selectCompanyRedPacketBalanceLogsListByStatus(createSTime, createETime);
 
-//        List<RedPacketMoneyVO> redPacketMoneyVOS = fsCourseRedPacketLogMapper.selectFsCourseAddRedPacketLogByCompany();
-//        for(RedPacketMoneyVO company:redPacketMoneyVOS){
-//            logger.info("红包余额回滚开始:{}",company);
-//        }
         Optional.ofNullable(companyRedPacketBalanceLogsList).ifPresent(list -> list.forEach(company -> {
 
             if(company.getRedPacketId()==null){// 无数据跳过
@@ -1772,30 +1838,36 @@ public class CompanyServiceImpl implements ICompanyService
                 return;
             }
 
-            if(!StringUtils.isEmpty(redLogs.getOutBatchNo())){
-                String batchId=checkMchTransferStatus(redLogs.getOutBatchNo(),redLogs.getCompanyId());
-                if (StringUtils.isNotBlank(batchId)) {
+            if(!StringUtils.isEmpty(redLogs.getBatchId())){
+                R result=checkMchTransferStatusByBatchID(redLogs.getBatchId(),redLogs.getCompanyId());
+                if("200".equals(result.get("code"))){
                     FsCourseRedPacketLog update = new FsCourseRedPacketLog();
-                    update.setLogId(redLogs.getLogId());
-                    update.setStatus(1);
                     update.setUpdateTime(new Date());
-                    update.setBatchId(batchId);
-                    fsCourseRedPacketLogMapper.updateFsCourseRedPacketLog(update);
+                    update.setLogId(redLogs.getLogId());
 
                     // 更新扣减状态
                     CompanyRedPacketBalanceLogs redBalanceLogs = new CompanyRedPacketBalanceLogs();
                     redBalanceLogs.setRedPacketId(company.getRedPacketId());
-                    redBalanceLogs.setStatus(1L);
-                    companyRedPacketBalanceLogsMapper.updateCompanyRedPacketBalanceLogsByRedPacketId(redBalanceLogs);
-                    return;
+
+                    if("success".equals(result.get("status"))){
+                        update.setStatus(1);
+                        fsCourseRedPacketLogMapper.updateFsCourseRedPacketLog(update);
+
+                        redBalanceLogs.setStatus(1L);
+                        companyRedPacketBalanceLogsMapper.updateCompanyRedPacketBalanceLogsByRedPacketId(redBalanceLogs);
+                        return;
+                    }else if("fail".equals(result.get("status"))){// 只对失败的部分进行回滚
+                        // 更新支付状态
+                        update.setStatus(2); // 已退回
+                        fsCourseRedPacketLogMapper.updateFsCourseRedPacketLog(update);
+
+                        redBalanceLogs.setStatus(2L);
+                        companyRedPacketBalanceLogsMapper.updateCompanyRedPacketBalanceLogsByRedPacketId(redBalanceLogs);
+                    }
                 }else {
-                    logger.error("未查询到商户转账批次号,进行退款,流水{}",company.getLogsId());
-                    // 更新支付状态
-                    updateBalanceStatus(company.getLogsId(), 2,company.getRemark()+";退回经销商"); // 更新为已退款
+                    logger.info("商户转账状态查询失败,流水{}",company.getLogsId());
+                    return;
                 }
-                logger.error("未查询到OutBatchNo,进行退款,流水{}",company.getLogsId());
-                // 更新支付状态
-                updateBalanceStatus(company.getLogsId(), 2,company.getRemark()+";退回经销商"); // 更新为已退款
             }else {
                 logger.error("红包记录表中存在商户批次号为null的异常数据,流水{}",company.getLogsId());
                 return;
@@ -1837,13 +1909,4 @@ public class CompanyServiceImpl implements ICompanyService
         }));
     }
 
-
-    private void updateBalanceStatus(Long logsId, Integer status,String remark){
-        FsCourseRedPacketLog redLogs = new FsCourseRedPacketLog();
-        redLogs.setLogId(logsId);
-        redLogs.setStatus(status);
-        redLogs.setRemark(remark);
-        fsCourseRedPacketLogMapper.updateFsCourseRedPacketLog(redLogs);
-    }
-
 }

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

@@ -131,7 +131,7 @@ public interface FsCourseAnswerLogsMapper
     int selectErrorCountByCourseVideo(@Param("videoId") Long videoId, @Param("userId") Long userId, @Param("qwUserId") String qwUserId,@Param("project") Long project);
 
     Long selectRedStatus(@Param("userId") Long userId, @Param("videoId") Long videoId, @Param("periodId") Long periodId);
-
+    Integer selectRedStatus2(@Param("userId") Long userId, @Param("videoId") Long videoId, @Param("periodId") Long periodId);
     List<FsCourseAnswerLogsListVO> selectFsCourseAnswerLogsListVONew(FsCourseAnswerLogsParam param);
 
     Long selectFsCourseAnswerLogsListVONewCount(FsCourseAnswerLogsParam param);

+ 12 - 3
fs-service/src/main/java/com/fs/course/service/impl/FsCourseProductOrderServiceImpl.java

@@ -383,6 +383,7 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
         if (merchantConfigId == null || merchantConfigId <= 0) {
             throw new CustomException("小程序没有配置商户信息");
         }
+
         MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
         FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
         String openId = null;
@@ -436,6 +437,8 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                 storePayment.setOpenId(openId);
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(courseProductOrder.getCourseOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
@@ -623,19 +626,25 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
         mapOrder.setRefundTime(new Date());
         courseProductOrderMapper.updateFsCourseProductOrder(mapOrder);
 
+
         if(courseProduct.getProductPrice().compareTo(new BigDecimal(0))==1){
             List<FsStorePayment> fsStorePayments = fsStorePaymentMapper.selectFsStorePaymentByPay(6, param.getCourseOrderId());
             if (fsStorePayments != null && fsStorePayments.size() == 1) {
                 FsStorePayment payment=fsStorePayments.get(0);
+                FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+                Long merConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                if(payment.getMerConfigId()!=null){
+                    merConfigId=payment.getMerConfigId();
+                }
+                MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(merConfigId);
                 if(payment.getPayMode().equals("wx")){
                     WxPayConfig payConfig = new WxPayConfig();
-                    SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                    FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+                    FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
                     payConfig.setAppId(param.getAppId());
                     payConfig.setMchId(fsPayConfig.getWxMchId());
                     payConfig.setMchKey(fsPayConfig.getWxMchKey());
 
-                    payConfig.setKeyPath(wxPayProperties.getKeyPath());
+                    payConfig.setKeyPath(fsPayConfig.getKeyPath());
 
                     payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                     payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));

+ 4 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseOrderServiceImpl.java

@@ -451,6 +451,8 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                 storePayment.setOpenId(openId);
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
@@ -622,6 +624,8 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
 //                storePayment.setOpenId(user.getMpOpenId());
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {

+ 9 - 3
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseServiceImpl.java

@@ -556,14 +556,20 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
             Long lxDay = fsCourseWatchLogMapper.selectByWatchlxDay(recordVO.getUserId(),recordVO.getProjectId());
             System.out.println("进入了连续观看天数:"+lxDay+"天");
             recordVO.setWatchLxCount(lxDay);
-
+            //中康小程序统计发送红包状态问题(未答题、未领取、发送成功->0 未领取  1  发送成功  2.没有就是未答题
             // 领取状态
-            Long count = fsCourseAnswerLogsMapper.selectRedStatus(recordVO.getUserId(), recordVO.getVideoId(), (Long) params.get("periodId"));
+            Integer status = fsCourseAnswerLogsMapper.selectRedStatus2(recordVO.getUserId(), recordVO.getVideoId(), (Long) params.get("periodId"));
+            if (status==null){
+                recordVO.setRedStatus(2);
+            }else{
+                recordVO.setRedStatus(status);
+            }
+/*
             if (Objects.nonNull(count) && count > 0) {
                 recordVO.setRedStatus(1);
             } else {
                 recordVO.setRedStatus(0);
-            }
+            }*/
         });
         return list;
     }

+ 4 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserVipOrderServiceImpl.java

@@ -304,6 +304,8 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                 storePayment.setOpenId(openId);
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
@@ -468,6 +470,8 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
 //                storePayment.setOpenId(user.getMpOpenId());
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {

+ 9 - 0
fs-service/src/main/java/com/fs/his/domain/FsStorePayment.java

@@ -100,6 +100,15 @@ public class FsStorePayment extends BaseEntity
     //小程序appId
     private String appId;
 
+    private Long merConfigId;
+
+    public Long getMerConfigId() {
+        return merConfigId;
+    }
+
+    public void setMerConfigId(Long merConfigId) {
+        this.merConfigId = merConfigId;
+    }
 
     public Integer getIsShare() {
         return isShare;

+ 12 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsInquiryOrderServiceImpl.java

@@ -343,9 +343,13 @@ public class FsInquiryOrderServiceImpl implements IFsInquiryOrderService
                         if (merchantConfigId == null || merchantConfigId <= 0) {
                             throw new CustomException("小程序没有配置商户信息");
                         }
-                        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+                        Long merConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                        if(payment.getMerConfigId()!=null){
+                            merConfigId=payment.getMerConfigId();
+                        }
+                        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(merConfigId);
                         FsPayConfig fsPayConfig = com.hc.openapi.tool.fastjson.JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
-                        payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
+                        payConfig.setAppId(fsPayConfig.getAppId());
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
 
@@ -1513,9 +1517,13 @@ public class FsInquiryOrderServiceImpl implements IFsInquiryOrderService
                     if (merchantConfigId == null || merchantConfigId <= 0) {
                         throw new CustomException("小程序没有配置商户信息");
                     }
-                    MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+                    Long merConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                    if(payment.getMerConfigId()!=null){
+                        merConfigId=payment.getMerConfigId();
+                    }
+                    MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(merConfigId);
                     FsPayConfig fsPayConfig = com.hc.openapi.tool.fastjson.JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
-                    payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
+                    payConfig.setAppId(fsPayConfig.getAppId());
                     payConfig.setMchId(fsPayConfig.getWxMchId());
                     payConfig.setMchKey(fsPayConfig.getWxMchKey());
 

+ 9 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -1053,6 +1053,8 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
@@ -1138,7 +1140,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         o.setAppId(appId);
                         //公司分账
                         try {
-                            HuiFuUtils.doDiv(o,fsPackageOrder.getCompanyId());
+                            HuiFuUtils.doDiv(o,fsPackageOrder.getCompanyId(),storePayment.getMerConfigId());
                             //存储分账明细
                             HuiFuUtils.saveDivItem(o, fsPackageOrder.getOrderSn(), storePayment.getPayCode());
                         } catch (Exception e) {
@@ -1285,6 +1287,8 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {
@@ -1414,6 +1418,8 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
                     if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
@@ -1545,6 +1551,8 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {

+ 6 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -493,11 +493,15 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
             if (merchantConfigId == null || merchantConfigId <= 0) {
                 throw new CustomException("小程序没有配置商户信息");
             }
-            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            Long merConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if(payment.getMerConfigId()!=null){
+                merConfigId=payment.getMerConfigId();
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(merConfigId);
             FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             if (payment.getPayMode().equals("wx")) {
                 WxPayConfig payConfig = new WxPayConfig();
-                payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
+                payConfig.setAppId(fsPayConfig.getAppId());
                 payConfig.setMchId(fsPayConfig.getWxMchId());
                 payConfig.setMchKey(fsPayConfig.getWxMchKey());
                 payConfig.setKeyPath(wxPayProperties.getKeyPath());

+ 4 - 3
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -3028,20 +3028,21 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 storePayment.setCompanyUserId(order.getCompanyUserId());
                 storePayment.setStoreId(order.getStoreId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setAppId(appId);
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
 
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
                         WxPayConfig payConfig = new WxPayConfig();
-                        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+                        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
                         payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
                         payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                         payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                         payConfig.setKeyPath(null);
-                        payConfig.setNotifyUrl(wxPayProperties.getNotifyUrl());
+                        payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
                         wxPayService.setConfig(payConfig);
                         WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
                         orderRequest.setOpenid(openId);//公众号支付提供用户openid

+ 3 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java

@@ -96,7 +96,6 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.TransferService;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
-import com.google.gson.Gson;
 import com.hc.openapi.tool.fastjson.JSON;
 import me.chanjar.weixin.common.error.WxErrorException;
 
@@ -1821,6 +1820,8 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
         storePayment.setOpenId(openId);
         storePayment.setUserId(user.getUserId());
         storePayment.setPayMode(merchantAppConfig.getMerchantType());
+        storePayment.setAppId(appId);
+        storePayment.setMerConfigId(merchantAppConfig.getId());
 
         if (fsStorePaymentMapper.insertFsStorePayment(storePayment) > 0) {
             if (merchantAppConfig.getMerchantType().equals("wx")) {
@@ -1862,7 +1863,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
                 o.setAppId(appId);
                 //公司分账
                 try {
-                    HuiFuUtils.doDiv(o,company.getCompanyId());
+                    HuiFuUtils.doDiv(o,company.getCompanyId(), storePayment.getMerConfigId());
                     //存储分账明细
                     HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
                 } catch (Exception e) {

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStorePaymentScrm.java

@@ -104,4 +104,7 @@ public class FsStorePaymentScrm extends BaseEntity
     //小程序appId(用于多汇付支付/退款)
     private String appId;
 
+    // 商户配置ID (用于多汇付支付/退款) 切换汇付后需要查询历史汇付配置信息退款
+    private Long merConfigId;
+
 }

+ 2 - 4
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java

@@ -1545,12 +1545,10 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
             FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             if (payment.getPayMode().equals("wx")) {
                 WxPayConfig payConfig = new WxPayConfig();
-                //SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                //FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
-                payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
+                payConfig.setAppId(payment.getAppId());
                 payConfig.setMchId(fsPayConfig.getWxMchId());
                 payConfig.setMchKey(fsPayConfig.getWxMchKey());
-                payConfig.setKeyPath(wxPayProperties.getKeyPath());
+                payConfig.setKeyPath(fsPayConfig.getKeyPath());
                 payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                 payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                 wxPayService.setConfig(payConfig);

+ 10 - 8
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -19,7 +19,6 @@ import com.fs.api.param.OrderListParam;
 import com.fs.api.vo.OrderListVO;
 import com.fs.api.vo.ProductListVO;
 import com.fs.common.config.FSSysConfig;
-import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.entity.SysDictData;
 import com.fs.common.core.redis.RedisCache;
@@ -33,7 +32,6 @@ import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.IpUtil;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
-import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.common.utils.ip.IpUtils;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.company.domain.*;
@@ -76,7 +74,6 @@ import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsInquiryOrderVO;
 import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
 import com.fs.his.vo.FsStoreOrderExcelVO;
-import com.fs.his.vo.*;
 import com.fs.his.vo.FsPrescribeVO;
 import com.fs.hisStore.config.FsErpConfig;
 import com.fs.hisStore.constants.ErpTypeEnum;
@@ -85,7 +82,6 @@ import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.vo.*;
 import com.fs.hisStore.vo.FsStoreOrderErpExportVO;
-import com.fs.hisStore.vo.FsStoreOrderExportVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
 import com.fs.hisStore.vo.FsStoreProductAttrValueVO;
@@ -153,7 +149,6 @@ import javax.annotation.PostConstruct;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.nio.charset.Charset;
-import java.sql.SQLException;
 import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -168,7 +163,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static com.fs.his.utils.PhoneUtil.decryptPhone;
-import static com.fs.his.utils.PhoneUtil.encryptPhone;
 import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
 
 /**
@@ -2508,7 +2502,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
                     if (payment.getPayMode() == null || payment.getPayMode().equals("wx")) {
                         WxPayConfig payConfig = new WxPayConfig();
-                        payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
+                        payConfig.setAppId(payment.getAppId());
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
                         payConfig.setKeyPath(fsPayConfig.getKeyPath());
@@ -4316,6 +4310,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 storePayment.setBusinessOrderId(order.getId().toString());
                 storePayment.setOrderId(order.getId());
                 storePayment.setAppId(fsCoursePlaySourceConfig.getAppid() == null ? "" : fsCoursePlaySourceConfig.getAppid());
+                storePayment.setMerConfigId(merchantAppConfig.getId());
                 fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
                 if (merchantAppConfig.getMerchantType().equals("hf")){
@@ -4327,7 +4322,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                     o.setGoodsDesc("商城订单支付");
                     o.setAppId(param.getAppId());
                     try {
-                        HuiFuUtils.doDiv(o,order.getCompanyId());
+
+                        HuiFuUtils.doDiv(o,order.getCompanyId(), storePayment.getMerConfigId());
                         //存储分账明细
                         HuiFuUtils.saveDivItem(o, order.getOrderCode(), storePayment.getPayCode());
                     } catch (Exception e) {
@@ -4465,6 +4461,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setBusinessOrderId(order.getId().toString());
             storePayment.setOrderId(order.getId());
             storePayment.setIsPayRemain(1);
+            storePayment.setMerConfigId(merchantAppConfig.getId());
+            storePayment.setAppId(param.getAppId());
             fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
             if (merchantAppConfig.getMerchantType().equals("hf")){
@@ -4593,6 +4591,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setUserId(user.getUserId());
             storePayment.setBusinessOrderId(order.getId().toString());
             storePayment.setOrderId(order.getId());
+            storePayment.setMerConfigId(merchantAppConfig.getId());
+            storePayment.setAppId(param.getAppId());
             fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
             if (merchantAppConfig.getMerchantType().equals("hf")){
@@ -4705,6 +4705,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setBusinessOrderId(order.getId().toString());
             storePayment.setOrderId(order.getId());
             storePayment.setIsPayRemain(1);
+            storePayment.setMerConfigId(merchantAppConfig.getId());
+            storePayment.setAppId(param.getAppId());
             fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
             if (merchantAppConfig.getMerchantType().equals("hf")){

+ 2 - 9
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -15,13 +15,11 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fs.common.annotation.DataScope;
-import com.fs.common.config.FSSysConfig;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.CustomException;
@@ -43,14 +41,12 @@ import com.fs.course.domain.FsCourseRedPacketLog;
 import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.course.service.IFsCourseRedPacketLogService;
-import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.mapper.FsUserWxMapper;
 import com.fs.his.mapper.MerchantAppConfigMapper;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.ConfigUtil;
-import com.fs.his.utils.HttpUtil;
 import com.fs.hisStore.config.StoreConfig;
 import com.fs.hisStore.enums.SysConfigEnum;
 import com.fs.hisStore.param.*;
@@ -59,14 +55,12 @@ import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
 import com.fs.huifuPay.service.HuiFuService;
-import com.fs.pay.pay.config.PayConfig;
 import com.fs.pay.pay.dto.WxJspayDTO;
 import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
 import com.fs.system.oss.CloudStorageService;
 import com.fs.system.oss.OSSFactory;
 import com.fs.system.service.ISysConfigService;
 import com.fs.utils.TwelveDigitSnowflake;
-import com.fs.wx.miniapp.config.WxMaProperties;
 import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.service.IFsUserScrmService;
 import com.fs.hisStore.vo.FsStorePaymentVO;
@@ -83,8 +77,6 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.TransferService;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.slf4j.Logger;
@@ -950,6 +942,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
             storePayment.setPayMode("hf");
         }
         storePayment.setAppId(param.getAppId());
+        storePayment.setMerConfigId(merchantAppConfig.getId());
         if (fsStorePaymentMapper.insertFsStorePayment(storePayment) > 0) {
             if (merchantAppConfig.getMerchantType().equals("wx")) {
                 //创建微信订单
@@ -990,7 +983,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
                 o.setAppId(appId);
                 //公司分账
                 try {
-                    HuiFuUtils.doDiv(o,company.getCompanyId());
+                    HuiFuUtils.doDiv(o,company.getCompanyId(), storePayment.getMerConfigId());
                     //存储分账明细
                     HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
                 } catch (Exception e) {

+ 24 - 17
fs-service/src/main/java/com/fs/huifuPay/sdk/opps/core/utils/HuiFuUtils.java

@@ -6,28 +6,22 @@ import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.company.domain.CompanyDivItem;
-import com.fs.company.mapper.CompanyDivConfigMapper;
 import com.fs.company.param.CompanyAcctInfo;
 import com.fs.company.service.ICompanyDivConfigService;
 import com.fs.company.service.ICompanyDivItemService;
-import com.fs.company.service.impl.CompanyDivConfigServiceImpl;
 import com.fs.company.vo.CompanyDivConfigVo;
-import com.fs.his.domain.FsPackageOrder;
-import com.fs.his.domain.FsPayConfig;
-import com.fs.his.domain.FsStoreOrder;
-import com.fs.his.domain.FsStorePayment;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
+import com.fs.his.domain.*;
 import com.fs.his.mapper.FsStorePaymentMapper;
+import com.fs.his.mapper.MerchantAppConfigMapper;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.huifuPay.domain.HuiFuConfirmOrder;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 import com.fs.huifuPay.service.HuiFuService;
-import com.fs.system.domain.SysConfig;
-import com.fs.system.mapper.SysConfigMapper;
-import com.google.gson.Gson;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -46,12 +40,19 @@ public class HuiFuUtils {
      *
      * @param huiFuCreateOrder
      * @param companyId
+     * @param merConfigId
      */
-    public static void doDiv(HuiFuCreateOrder huiFuCreateOrder, Long companyId) throws Exception {
+    public static void doDiv(HuiFuCreateOrder huiFuCreateOrder, Long companyId, Long merConfigId) throws Exception {
         //默认汇付账户
-        SysConfigMapper sysConfigMapper = SpringUtils.getBean(SysConfigMapper.class);
-        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+        FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper = SpringUtils.getBean(FsCoursePlaySourceConfigMapper.class);
+        MerchantAppConfigMapper merchantAppConfigMapper = SpringUtils.getBean(MerchantAppConfigMapper.class);
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(huiFuCreateOrder.getAppId());
+        Long merConfigIds = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if(merConfigId!=null){
+            merConfigIds=merConfigId;
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(merConfigIds);
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
         String defaultHuifuId = fsPayConfig.getHuifuId();
         //查询是否开启分账
         if (companyId != null) {
@@ -230,9 +231,15 @@ public class HuiFuUtils {
             if (payPrice.compareTo(reMoney) > 0) {
                 //部分退款
                 if (companyDivItem != null) {
-                    SysConfigMapper sysConfigMapper = SpringUtils.getBean(SysConfigMapper.class);
-                    SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                    FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+                    FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper = SpringUtils.getBean(FsCoursePlaySourceConfigMapper.class);
+                    MerchantAppConfigMapper merchantAppConfigMapper = SpringUtils.getBean(MerchantAppConfigMapper.class);
+                    FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
+                    Long merConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                    if(payment.getMerConfigId()!=null){
+                        merConfigId=payment.getMerConfigId();
+                    }
+                    MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(merConfigId);
+                    FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
                     String defaultHuiFuId = fsPayConfig.getHuifuId(); //默认汇付id
 
                     String detail = companyDivItem.getDetail();

+ 6 - 42
fs-service/src/main/java/com/fs/huifuPay/service/impl/HuiFuServiceImpl.java

@@ -51,15 +51,8 @@ public class HuiFuServiceImpl implements HuiFuService {
         try {
 
             if (order.getAppId() != null) {
-                FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
-                FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(order.getAppId());
-                if (fsHfpayConfig != null) {
-                    //多汇付支付获取配置
-                    doInit(getMerConfig(fsHfpayConfig));
-                } else {
-                    //多小程序
-                    doInit(getMerConfig(order.getAppId()));
-                }
+                //多小程序
+                doInit(getMerConfig(order.getAppId()));
             } else {
                 doInit(getMerConfig());
             }
@@ -140,15 +133,8 @@ public class HuiFuServiceImpl implements HuiFuService {
     @Override
     public HuiFuQueryOrderResult queryOrder(V2TradePaymentScanpayQueryRequest request) throws Exception{
         if (request.getAppId() != null) {
-            FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
-            FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(request.getAppId());
-            if (fsHfpayConfig != null) {
-                //多汇付支付获取配置
-                doInit(getMerConfig(fsHfpayConfig));
-            } else {
-                //多小程序
-                doInit(getMerConfig());
-            }
+            //多汇付支付获取配置
+            doInit(getMerConfig(request.getAppId()));
         } else {
             doInit(getMerConfig());
         }
@@ -301,15 +287,8 @@ public class HuiFuServiceImpl implements HuiFuService {
         HuiFuQueryOrderResult result =null;
         try {
             if (order.getAppId() != null) {
-                FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
-                FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(order.getAppId());
-                if (fsHfpayConfig != null) {
-                    //多汇付支付获取配置
-                    doInit(getMerConfig(fsHfpayConfig));
-                } else {
-                    //多小程序
-                    doInit(getMerConfig());
-                }
+                //多汇付支付获取配置
+                doInit(getMerConfig(order.getAppId()));
             } else {
                 doInit(getMerConfig());
             }
@@ -372,21 +351,6 @@ public class HuiFuServiceImpl implements HuiFuService {
         return merConfig;
     }
 
-    public MerConfig getMerConfig(FsHfpayConfig fsHfpayConfig) {
-        MerConfig merConfig = new MerConfig();
-        merConfig.setProcutId(fsHfpayConfig.getHfProductId());
-        merConfig.setSysId(fsHfpayConfig.getHfSysId());
-        merConfig.setRsaPrivateKey(fsHfpayConfig.getHfRsaPrivateKey());
-        merConfig.setRsaPublicKey(fsHfpayConfig.getHfRsaPublicKey());
-        merConfig.setHuifuId(fsHfpayConfig.getHuifuId());
-
-        FsPayConfig fsPayConfig = new FsPayConfig();
-        BeanUtils.copyProperties(fsHfpayConfig,fsPayConfig);
-
-        config = fsPayConfig;
-        return merConfig;
-    }
-
     public MerConfig getMerConfig(String appId) {
         if (StringUtils.isBlank(appId)) {
             throw new IllegalArgumentException("appId不能为空");

+ 2 - 2
fs-service/src/main/resources/application-config-druid-sft.yml

@@ -82,8 +82,8 @@ tencent_cloud_config:
 cloud_host:
   company_name: 四福堂
   projectCode: SFT
-  spaceName:
-  volcengineUrl:
+  spaceName: cqsft-2114522511
+  volcengineUrl: https://cqsftvolcengine.ylrztop.com
 
 #看课授权时显示的头像
 headerImg:

+ 1 - 1
fs-service/src/main/resources/mapper/company/CompanyRedPacketBalanceLogsMapper.xml

@@ -89,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="SET" suffixOverrides=",">
             <if test="status != null">status = #{status},</if>
         </trim>
-        where red_packet_id = #{redPacketId}
+        where red_packet_id = #{redPacketId} and logs_type = 15
     </update>
 
     <delete id="deleteCompanyRedPacketBalanceLogsByLogsId" parameterType="Long">

+ 9 - 1
fs-service/src/main/resources/mapper/course/FsCourseAnswerLogsMapper.xml

@@ -196,7 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         ) AS paged_ids ON cal.log_id = paged_ids.log_id
     </select>
-    
+
     <select id="selectRedStatus" resultType="java.lang.Long">
         select count(log_id)
         from fs_course_red_packet_log
@@ -205,5 +205,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and period_id = #{periodId}
         </if>
     </select>
+    <select id="selectRedStatus2" resultType="java.lang.Integer">
+        select `status`
+        from fs_course_red_packet_log
+        where user_id = #{userId} and video_id = #{videoId}
+        <if test="periodId != null">
+            and period_id = #{periodId}
+        </if>
+    </select>
 
 </mapper>

+ 2 - 0
fs-service/src/main/resources/mapper/his/FsStorePaymentMapper.xml

@@ -97,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareMoney != null">share_money,</if>
             <if test="isShare != null">is_share,</if>
             <if test="appId != null">app_id,</if>
+            <if test="merConfigId != null">mer_config_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="payCode != null">#{payCode},</if>
@@ -125,6 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareMoney != null">#{shareMoney},</if>
             <if test="isShare != null">#{isShare},</if>
             <if test="appId != null">#{appId},</if>
+            <if test="merConfigId != null">#{merConfigId},</if>
          </trim>
     </insert>
 

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

@@ -207,7 +207,7 @@ public class WxH5MpController {
 //            newUser.setCompanyUserId(companyUser.getUserId());
             newUser.setUnionId(wxMpUser.getUnionId());
             newUser.setCreateTime(new Date());
-            newUser.setStatus(company != null && company.getFsUserIsDefaultBlack() == 1 ? 0 : 1);
+//            newUser.setStatus(company != null && company.getFsUserIsDefaultBlack() == 1 ? 0 : 1);
             // 新用户 - 添加 appId
             newUser.setAppId(param.getAppId());
             userService.insertFsUser(newUser);

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

@@ -190,7 +190,7 @@ public class CourseFsUserLoginController extends AppBaseController {
      */
     private FsUser createUser(LoginMaWxParam param, WxMaJscode2SessionResult session, WxMaPhoneNumberInfo phoneNoInfo, Company company, CompanyUser companyUser) {
         FsUser user = new FsUser();
-        user.setStatus((company != null ? company.getFsUserIsDefaultBlack() : 0) == 1 ? 0 : 1);
+        user.setStatus(1);
         user.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
         user.setCreateTime(new Date());
         if (param.getAuthType() == 1 && phoneNoInfo != null) {

+ 32 - 32
fs-user-app/src/main/java/com/fs/app/controller/live/LiveCompletionPointsController.java

@@ -87,20 +87,20 @@ public class LiveCompletionPointsController extends AppBaseController {
     @GetMapping("/info")
     public R getInfo(@RequestParam Long liveId) {
         Long userId = Long.parseLong(getUserId());
-        
+
         // 1. 获取用户积分余额
         FsUser user = fsUserService.selectFsUserByUserId(userId);
         Long integral = user != null && user.getIntegral() != null ? user.getIntegral() : 0L;
-        
+
         // 2. 获取完课记录列表(包含已领取和未领取)
         List<LiveCompletionPointsRecord> records = completionPointsRecordService.getUserRecords(liveId, userId);
-        
+
         // 3. 统计信息
         long totalPoints = records.stream()
                 .filter(r -> r.getReceiveStatus() == 1)
                 .mapToLong(LiveCompletionPointsRecord::getPointsAwarded)
                 .sum();
-        
+
         long unreceivedCount = records.stream()
                 .filter(r -> r.getReceiveStatus() == 0)
                 .count();
@@ -111,7 +111,7 @@ public class LiveCompletionPointsController extends AppBaseController {
         result.put("totalDays", records.size());  // 累计看直播天数
         result.put("unreceivedCount", unreceivedCount);  // 未领取记录数
         result.put("records", records);  // 完课记录列表
-        
+
         return R.ok().put("data", result);
     }
 
@@ -121,7 +121,7 @@ public class LiveCompletionPointsController extends AppBaseController {
     @PostMapping("/test/create")
     public R testCreateRecord(@RequestParam Long liveId, @RequestParam(required = false) Long watchDuration) {
         Long userId = Long.parseLong(getUserId());
-        
+
         try {
             // 调用完课记录创建方法(watchDuration为null时会自动从数据库累计)
             completionPointsRecordService.checkAndCreateCompletionRecord(liveId, userId, watchDuration);
@@ -139,7 +139,7 @@ public class LiveCompletionPointsController extends AppBaseController {
     @GetMapping("/remaining-time")
     public R getRemainingTime(@RequestParam Long liveId) {
         Long userId = Long.parseLong(getUserId());
-        
+
         try {
             // 1. 获取直播间信息
             Live live = liveService.selectLiveByLiveId(liveId);
@@ -149,7 +149,7 @@ public class LiveCompletionPointsController extends AppBaseController {
 
             // 2. 查询当前用户和当前直播间的最近一次完课记录(不限制日期)
             LiveCompletionPointsRecord record = completionPointsRecordMapper.selectLatestByUserAndLiveId(liveId, userId);
-            
+
             // 3. 如果没有记录,查询直播间配置并生成记录
             if (record == null) {
                 record = completionPointsRecordService.createCompletionRecord(liveId, userId);
@@ -158,9 +158,9 @@ public class LiveCompletionPointsController extends AppBaseController {
             // 4. 计算剩余时长
             RemainingTimeVO vo = new RemainingTimeVO();
             Long videoDuration = live.getDuration() != null ? live.getDuration() : 0L;
-            Long watchDuration = record != null && record.getWatchDuration() != null 
+            Long watchDuration = record != null && record.getWatchDuration() != null
                     ? record.getWatchDuration() : 0L;
-            
+
             vo.setVideoDuration(videoDuration);
             if (record != null) {
                 vo.setCompletionRate(record.getCompletionRate());
@@ -168,7 +168,7 @@ public class LiveCompletionPointsController extends AppBaseController {
             vo.setWatchDuration(watchDuration);
             vo.setRemainingTime(Math.max(0, videoDuration - watchDuration));
             vo.setHasReceived(record != null && record.getReceiveStatus() != null && record.getReceiveStatus() == 1);
-            
+
             return R.ok().put("data", vo);
         } catch (Exception e) {
             return R.error("查询失败: " + e.getMessage());
@@ -183,7 +183,7 @@ public class LiveCompletionPointsController extends AppBaseController {
     @PostMapping("/update-watch-duration")
     public R updateWatchDuration(@RequestParam Long liveId, @RequestParam Long watchDuration) {
         Long userId = Long.parseLong(getUserId());
-        
+
         try {
             // 1. 获取直播间信息
             Live live = liveService.selectLiveByLiveId(liveId);
@@ -194,7 +194,7 @@ public class LiveCompletionPointsController extends AppBaseController {
             // 2. 判断当前时间是否在直播期间(状态为2,直播中)
             boolean isLiveInProgress = false;
             LocalDateTime now = LocalDateTime.now();
-            
+
             if (live.getStatus() != null && live.getStatus() == 2) {
                 // status=2 表示直播中
                 isLiveInProgress = true;
@@ -210,20 +210,20 @@ public class LiveCompletionPointsController extends AppBaseController {
 
             // 3. 查询当前直播间的完课记录(不限制日期)
             LiveCompletionPointsRecord record = completionPointsRecordMapper.selectLatestByUserAndLiveId(liveId, userId);
-            
+
             // 4. 计算看课时长
             Date updateTime = null;
             if (record != null && record.getUpdateTime() != null) {
                 updateTime = record.getUpdateTime();
             }
-            
+
             // 判断更新时间与直播间开始时间的关系
-            Date startTime = live.getStartTime() != null 
+            Date startTime = live.getStartTime() != null
                     ? java.sql.Timestamp.valueOf(live.getStartTime()) : null;
-            
+
             Date currentTime = new Date();
             long timeDiff = 0L;
-            
+
             if (updateTime != null && startTime != null) {
                 if (updateTime.before(startTime)) {
                     // 更新时间小于直播间开始时间,使用直播间开始时间进行计算
@@ -236,7 +236,7 @@ public class LiveCompletionPointsController extends AppBaseController {
                 // 没有更新记录,使用直播间开始时间计算
                 timeDiff = (currentTime.getTime() - startTime.getTime()) / 1000; // 转换为秒
             }
-            
+
             // 5. 如果请求传入的时间大于这个时间差,就使用计算出的看课时长,否则使用请求传入的时长
             Long finalWatchDuration;
             if (watchDuration > timeDiff) {
@@ -246,17 +246,17 @@ public class LiveCompletionPointsController extends AppBaseController {
                 // 否则使用请求传入的时长
                 finalWatchDuration = watchDuration;
             }
-            
+
             // 6. 更新完课记录中的看课时长
             if (record == null) {
                 // 如果没有记录,先创建记录
                 record = completionPointsRecordService.createCompletionRecord(liveId, userId);
             } else {
                 // 更新现有记录的看课时长
-                Long currentWatchDuration = record.getWatchDuration() != null 
+                Long currentWatchDuration = record.getWatchDuration() != null
                         ? record.getWatchDuration() : 0L;
                 record.setWatchDuration(currentWatchDuration + finalWatchDuration);
-                
+
                 // 重新计算完课比例
                 Long videoDuration = live.getDuration();
                 if (videoDuration != null && videoDuration > 0) {
@@ -268,15 +268,15 @@ public class LiveCompletionPointsController extends AppBaseController {
                     }
                     record.setCompletionRate(completionRate);
                 }
-                
+
                 completionPointsRecordMapper.updateRecord(record);
             }
 
             UpdateWatchDurationVO vo = new UpdateWatchDurationVO();
             vo.setWatchDuration(finalWatchDuration);
-            vo.setTotalWatchDuration(record != null && record.getWatchDuration() != null 
+            vo.setTotalWatchDuration(record != null && record.getWatchDuration() != null
                     ? record.getWatchDuration() : finalWatchDuration);
-            
+
             return R.ok().put("data", vo);
         } catch (Exception e) {
             return R.error("更新失败: " + e.getMessage());
@@ -294,11 +294,11 @@ public class LiveCompletionPointsController extends AppBaseController {
     @RepeatSubmit
     public R receivePoints(@RequestParam Long liveId) {
         Long userId = Long.parseLong(getUserId());
-        
+
         try {
             // 1. 查询当前用户和当前直播间的最近一次完课记录(不限制日期)
             LiveCompletionPointsRecord record = completionPointsRecordMapper.selectLatestByUserAndLiveId(liveId, userId);
-            
+
             if (record == null) {
                 return R.error("您还没有看课记录,无法领取积分");
             }
@@ -361,7 +361,7 @@ public class LiveCompletionPointsController extends AppBaseController {
             vo.setRecord(receivedRecord);
             vo.setPoints(receivedRecord.getPointsAwarded());
             vo.setContinuousDays(receivedRecord.getContinuousDays());
-            
+
             return R.ok().put("data", vo);
         } catch (BaseException e) {
             return R.error(e.getMessage());
@@ -377,13 +377,13 @@ public class LiveCompletionPointsController extends AppBaseController {
     @GetMapping("/integral-logs")
     public R getIntegralLogs(@RequestParam(required = false) Integer type) {
         Long userId = Long.parseLong(getUserId());
-        
+
         try {
             FsUserIntegralLogs query = new FsUserIntegralLogs();
             query.setUserId(userId);
-            
+
             List<FsUserIntegralLogs> logs = fsUserIntegralLogsService.selectFsUserIntegralLogsList(query);
-            
+
             // 如果指定了类型,进行过滤
             if (type != null) {
                 if (type == 1) {
@@ -394,7 +394,7 @@ public class LiveCompletionPointsController extends AppBaseController {
                     logs.removeIf(log -> log.getIntegral() == null || log.getIntegral() >= 0);
                 }
             }
-            
+
             return R.ok().put("data", logs);
         } catch (Exception e) {
             return R.error("查询失败: " + e.getMessage());