|
@@ -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());
|