zyp 3 týždňov pred
rodič
commit
2a9e12fec2

+ 0 - 49
fs-qw-api-msg/src/main/java/com/fs/app/config/QWConfigProperties.java

@@ -1,49 +0,0 @@
-package com.fs.app.config;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Component
-public class QWConfigProperties {
-
-    @Value("${custom.token}")
-    private String token;
-
-    @Value("${custom.encoding-aes-key}")
-    private String encodingAesKey;
-
-    @Value("${custom.corp-id}")
-    private String corpId;
-    @Value("${custom.secret}")
-    private String secret;
-
-    @Value("${custom.private-key-path}")
-    private String privateKeyPath;
-
-    @Value("${custom.webhook-url}")
-    private String webhookUrl;
-
-    public String getToken() {
-        return token;
-    }
-
-    public String getEncodingAesKey() {
-        return encodingAesKey;
-    }
-
-    public String getCorpId() {
-        return corpId;
-    }
-
-    public String getSecret() {
-        return secret;
-    }
-
-    public String getPrivateKeyPath() {
-        return privateKeyPath;
-    }
-
-    public String getWebhookUrl() {
-        return webhookUrl;
-    }
-}

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

@@ -64,7 +64,7 @@ public interface IFsCourseRedPacketLogService
      */
     public int deleteFsCourseRedPacketLogByLogId(Long logId);
 
-    R syncRedPacket(String outBatchNo);
+//    R syncRedPacket(String outBatchNo);
 
     R syncRedPacket(String outBatchNo, String batchId);
 

+ 11 - 11
fs-service/src/main/java/com/fs/course/service/impl/FsCourseRedPacketLogServiceImpl.java

@@ -122,17 +122,17 @@ public class FsCourseRedPacketLogServiceImpl implements IFsCourseRedPacketLogSer
         return fsCourseRedPacketLogMapper.deleteFsCourseRedPacketLogByLogId(logId);
     }
 
-    @Override
-    public R syncRedPacket(String outBatchNo) {
-        FsCourseRedPacketLog log = fsCourseRedPacketLogMapper.selectFsCourseRedPacketLogByBatchNo(outBatchNo);
-        if (log!=null){
-            log.setStatus(1);
-            log.setUpdateTime(new Date());
-            fsCourseRedPacketLogMapper.updateFsCourseRedPacketLog(log);
-            return R.ok();
-        }
-        return R.error("批次不存在");
-    }
+//    @Override
+//    public R syncRedPacket(String outBatchNo) {
+//        FsCourseRedPacketLog log = fsCourseRedPacketLogMapper.selectFsCourseRedPacketLogByBatchNo(outBatchNo);
+//        if (log!=null){
+//            log.setStatus(1);
+//            log.setUpdateTime(new Date());
+//            fsCourseRedPacketLogMapper.updateFsCourseRedPacketLog(log);
+//            return R.ok();
+//        }
+//        return R.error("批次不存在");
+//    }
 
     @Override
     public R syncRedPacket(String outBatchNo, String batchId) {

+ 42 - 44
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -204,6 +204,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
     @Autowired
     private SysDictDataMapper dictDataMapper;
 
+    @Autowired
+    private FsCourseAnswerLogsMapper courseAnswerLogsMapper;
+
 
     /**
      * 查询课堂视频
@@ -929,6 +932,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         if (log == null) {
             return R.error("无记录");
         }
+
+        FsCourseAnswerLogs rightLog = courseAnswerLogsMapper.selectRightLogByCourseVideo(param.getVideoId(), param.getUserId(), param.getQwUserId());
+
+        if (rightLog == null) {
+            logger.error("未答题:{}",param.getUserId());
+            return R.error("未答题");
+        }
         if (log.getRewardType() != null) {
             FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(),param.getPeriodId());
             if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 1) {
@@ -1110,27 +1120,17 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
 
     private void handleFsUserWx(FsUser user, String appId) {
-        // 尝试更新
-        boolean updated = fsUserWxService.lambdaUpdate()
-                .eq(FsUserWx::getFsUserId, user.getUserId())
-                .eq(FsUserWx::getAppId,appId )
-                .eq(FsUserWx::getOpenId, user.getMaOpenId())
-//                .set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
-                .set(FsUserWx::getUpdateTime, new Date())
-                .update();
-
-        // 如果更新失败(记录不存在),则插入
-        if (!updated) {
-            FsUserWx fsUserWx = new FsUserWx();
-            fsUserWx.setType(1);
-            fsUserWx.setFsUserId(user.getUserId());
-            fsUserWx.setAppId(appId);
-            fsUserWx.setOpenId(user.getMaOpenId());
-//            fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
-            fsUserWx.setCreateTime(new Date());
-            fsUserWx.setUpdateTime(new Date());
-            fsUserWxService.save(fsUserWx);
-        }
+        FsUserWx fsUserWx = new FsUserWx();
+        fsUserWx.setType(1);
+        fsUserWx.setFsUserId(user.getUserId());
+        fsUserWx.setAppId(appId);
+        fsUserWx.setOpenId(user.getCourseMaOpenId());
+        fsUserWx.setUnionId(user.getUnionId());
+        fsUserWx.setCreateTime(new Date());
+        fsUserWx.setUpdateTime(new Date());
+        fsUserWxService.saveOrUpdateByUniqueKey(fsUserWx);
+
+        logger.info("zyp \n 【更新或插入用户与小程序{}的绑定关系】:{}", appId, user.getUserId());
     }
 
     /**
@@ -1144,20 +1144,19 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
      * @return 处理结果
      */
     private R sendRedPacketRewardFsUser(FsCourseSendRewardUParam param, FsUser user, FsCourseWatchLog log, FsUserCourseVideo video, CourseConfig config) {
-        // 判断是否属于领取红包时间(会员看课发放红包)
-        if (param.getPeriodId()!=null && param.getPeriodId()>0) {
-            FsUserCoursePeriodDays periodDays = new FsUserCoursePeriodDays();
-            periodDays.setVideoId(param.getVideoId());
-            periodDays.setPeriodId(param.getPeriodId());
-            //正常情况是只能查询到一条,之前可能存在重复的脏数据,暂使用查询list的方式
-            List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectFsUserCoursePeriodDaysList(periodDays);
-            if(fsUserCoursePeriodDays != null && !fsUserCoursePeriodDays.isEmpty()){
-                periodDays = fsUserCoursePeriodDays.get(0);
-            }
-            if(periodDays != null && periodDays.getLastJoinTime() !=null && LocalDateTime.now().isAfter(periodDays.getLastJoinTime())) {
-                return R.error(403,"已超过领取红包时间");
-            }
+
+        FsUserCoursePeriodDays periodDays = new FsUserCoursePeriodDays();
+        periodDays.setVideoId(param.getVideoId());
+        periodDays.setPeriodId(param.getPeriodId());
+        //正常情况是只能查询到一条,之前可能存在重复的脏数据,暂使用查询list的方式
+        List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectFsUserCoursePeriodDaysList(periodDays);
+        if(fsUserCoursePeriodDays != null && !fsUserCoursePeriodDays.isEmpty()){
+            periodDays = fsUserCoursePeriodDays.get(0);
         }
+        if(periodDays != null && periodDays.getLastJoinTime() !=null && LocalDateTime.now().isAfter(periodDays.getLastJoinTime())) {
+            return R.error(403,"已超过领取红包时间");
+        }
+
 
         // 确定红包金额
         BigDecimal amount = BigDecimal.ZERO;
@@ -1171,7 +1170,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         // 准备发送红包参数
         WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
-//        packetParam.setOpenId(getOpenId(user.getUserId(), param.getCompanyId(), param.getSource()));
         packetParam.setOpenId(user.getMpOpenId());
         // 来源是小程序切换openId
         if (param.getSource() == 2) {
@@ -1181,7 +1179,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 //                return R.error("销售公司参数错误,未绑定小程序");
 //            }
             FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
-            if (fsUserWx ==null || fsUserWx.getOpenId()==null){
+            if (fsUserWx ==null){
+                if (user.getCourseMaOpenId()==null){
+                    logger.error("zyp \n 【转账openId参数错误】:{}", user.getUserId());
+                    return R.error("openId参数错误");
+                }
                 packetParam.setOpenId(user.getCourseMaOpenId());
                 try {
                     handleFsUserWx(user,param.getAppId());
@@ -1192,10 +1194,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             }else {
                 packetParam.setOpenId(fsUserWx.getOpenId());
             }
-
-            System.out.println("小程序id"+user.getCourseMaOpenId());
-            //查出公司绑定openid并赋值
-//            packetParam.setOpenId(fsUserWx.getOpenId());
         }
         packetParam.setAmount(amount);
         packetParam.setSource(param.getSource());
@@ -1205,9 +1203,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         System.out.println("红包金额"+amount);
         System.out.println("红包商户号"+packetParam);
-        if (ObjectUtils.isNotEmpty(config.getIsNegative())&&config.getIsNegative() == 1) {
-            return processRedPacket(config, packetParam, param, amount, log);
-        }
+//        if (ObjectUtils.isNotEmpty(config.getIsNegative())&&config.getIsNegative() == 1) {
+//            return processRedPacket(config, packetParam, param, amount, log);
+//        }
         //2025.6.19 红包金额为0的时候
         if (amount.compareTo(BigDecimal.ZERO)>0){
 
@@ -1242,10 +1240,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
                     redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
                 }else {
                     redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
+                    redPacketLog.setBatchId(sendRedPacket.get("batchId").toString());
                 }
                 // 添加红包记录
                 redPacketLog.setCourseId(param.getCourseId());
-//            redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
                 redPacketLog.setCompanyId(param.getCompanyId());
                 redPacketLog.setUserId(param.getUserId());
                 redPacketLog.setVideoId(param.getVideoId());

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

@@ -571,7 +571,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
 
         try {
             TransferBatchesResult transferBatchesResult = transferService.transferBatches(request);
-            return R.ok("发送红包成功").put("orderCode", transferBatchesResult.getOutBatchNo());
+            return R.ok("发送红包成功").put("orderCode", transferBatchesResult.getOutBatchNo()).put("batchId", transferBatchesResult.getBatchId());
         } catch (WxPayException e) {
             e.printStackTrace();
             return R.error("发送失败");
@@ -597,8 +597,8 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
             signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
             WxPayTransferBatchesNotifyV3Result result = wxPayService.parseTransferBatchesNotifyV3Result(notifyData,signatureHeader);
             logger.info("到零钱回调:{}",result.getResult());
-            if (result.getResult().getBatchStatus().equals("FINISHED")) {
-                R r = redPacketLogService.syncRedPacket(result.getResult().getOutBatchNo());
+            if (result.getResult().getBatchStatus().equals("FINISHED") && result.getResult().getFailNum()==0) {
+                R r = redPacketLogService.syncRedPacket(result.getResult().getOutBatchNo(),result.getResult().getBatchId());
                 logger.info("result:{}",r);
                 if (r.get("code").equals(200)){
                     return WxPayNotifyResponse.success("处理成功");
@@ -720,7 +720,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
             TransferBillsNotifyResult result = wxPayService.parseTransferBillsNotifyV3Result(notifyData,signatureHeader);
             logger.info("到零钱回调:{}",result.getResult());
             if (result.getResult().getState().equals("SUCCESS")) {
-                R r = redPacketLogService.syncRedPacket(result.getResult().getOutBillNo());
+                R r = redPacketLogService.syncRedPacket(result.getResult().getOutBillNo(),result.getResult().getTransferBillNo());
                 logger.info("result:{}",r);
                 if (r.get("code").equals(200)){
                     return WxPayNotifyResponse.success("处理成功");