|
@@ -407,7 +407,21 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
if (fsUser.getStatus()==0){
|
|
if (fsUser.getStatus()==0){
|
|
return R.error("会员被停用,无权限,请联系客服!");
|
|
return R.error("会员被停用,无权限,请联系客服!");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+// if (param.getIsOpenCourse()!=null&¶m.getIsOpenCourse()==1){
|
|
|
|
+// FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoByUserId(param.getUserId(), param.getVideoId());
|
|
|
|
+// if (log==null){
|
|
|
|
+// FsCourseWatchLog userLog = new FsCourseWatchLog();
|
|
|
|
+// BeanUtils.copyProperties(param,log);
|
|
|
|
+// userLog.setSendType(0);
|
|
|
|
+// userLog.setUserId(param.getUserId());
|
|
|
|
+// userLog.setVideoId(param.getVideoId());
|
|
|
|
+// userLog.setDuration(0L);
|
|
|
|
+// userLog.setCreateTime(new Date());
|
|
|
|
+// userLog.setLogType(3);
|
|
|
|
+// courseWatchLogMapper.insertFsCourseWatchLog(log);
|
|
|
|
+// }
|
|
|
|
+// return R.ok();
|
|
|
|
+// }
|
|
String msg = "<div style=\"color: red;margin-bottom: 15px;font-weight: bold;\">本课程为会员独享<br>请长按二维码</div>\n" +
|
|
String msg = "<div style=\"color: red;margin-bottom: 15px;font-weight: bold;\">本课程为会员独享<br>请长按二维码</div>\n" +
|
|
"\t\t\t\t\t<div style=\"color: #999;font-size: 14px;font-weight: bold;\">添加伴学助手免费领取会员权限</div>";
|
|
"\t\t\t\t\t<div style=\"color: #999;font-size: 14px;font-weight: bold;\">添加伴学助手免费领取会员权限</div>";
|
|
// try {
|
|
// try {
|
|
@@ -977,8 +991,12 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
if (param.getSource() == 2) {
|
|
if (param.getSource() == 2) {
|
|
//处理多小程序问题
|
|
//处理多小程序问题
|
|
FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
- if (fsUserWx ==null || fsUserWx.getOpenId()==null){
|
|
|
|
- packetParam.setOpenId(user.getCourseMaOpenId());
|
|
|
|
|
|
+ if (fsUserWx ==null){
|
|
|
|
+ try {
|
|
|
|
+ handleFsUserWx(user,param.getAppId());
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId());
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
packetParam.setOpenId(fsUserWx.getOpenId());
|
|
packetParam.setOpenId(fsUserWx.getOpenId());
|
|
}
|
|
}
|
|
@@ -1087,6 +1105,31 @@ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 发放红包奖励
|
|
* 发放红包奖励
|
|
*
|
|
*
|
|
@@ -1130,18 +1173,26 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
// 来源是小程序切换openId
|
|
// 来源是小程序切换openId
|
|
if (param.getSource() == 2) {
|
|
if (param.getSource() == 2) {
|
|
//处理多小程序问题
|
|
//处理多小程序问题
|
|
- Company company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
|
- if (company.getCourseMiniAppId()==null){
|
|
|
|
- return R.error("销售公司参数错误,未绑定小程序");
|
|
|
|
- }
|
|
|
|
- FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(company.getCourseMiniAppId(),user.getUserId(),1);
|
|
|
|
|
|
+// Company company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
|
+// if (company.getCourseMiniAppId()==null){
|
|
|
|
+// return R.error("销售公司参数错误,未绑定小程序");
|
|
|
|
+// }
|
|
|
|
+ FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
if (fsUserWx ==null || fsUserWx.getOpenId()==null){
|
|
if (fsUserWx ==null || fsUserWx.getOpenId()==null){
|
|
- return R.error("小程序openId参数缺失");
|
|
|
|
|
|
+ packetParam.setOpenId(user.getCourseMaOpenId());
|
|
|
|
+ try {
|
|
|
|
+ handleFsUserWx(user,param.getAppId());
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else {
|
|
|
|
+ packetParam.setOpenId(fsUserWx.getOpenId());
|
|
}
|
|
}
|
|
|
|
|
|
System.out.println("小程序id"+user.getCourseMaOpenId());
|
|
System.out.println("小程序id"+user.getCourseMaOpenId());
|
|
//查出公司绑定openid并赋值
|
|
//查出公司绑定openid并赋值
|
|
- packetParam.setOpenId(fsUserWx.getOpenId());
|
|
|
|
|
|
+// packetParam.setOpenId(fsUserWx.getOpenId());
|
|
}
|
|
}
|
|
packetParam.setAmount(amount);
|
|
packetParam.setAmount(amount);
|
|
packetParam.setSource(param.getSource());
|
|
packetParam.setSource(param.getSource());
|
|
@@ -1468,7 +1519,29 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
if (fsUser == null){
|
|
if (fsUser == null){
|
|
return ResponseResult.fail(404,"当前用户信息不存在");
|
|
return ResponseResult.fail(404,"当前用户信息不存在");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //公开课
|
|
|
|
+ if (param.getIsOpenCourse()!=null && param.getIsOpenCourse()==1){
|
|
|
|
+ FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getCourseWatchLogByUser(param.getUserId(), param.getVideoId());
|
|
|
|
+ //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
|
|
|
|
+ if(watchCourseVideo != null){
|
|
|
|
+ FsCourseWatchLog updateLog = new FsCourseWatchLog();
|
|
|
|
+ updateLog.setUpdateTime(new Date());
|
|
|
|
+ courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
|
|
|
|
+ } else {
|
|
|
|
+ FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
|
|
|
|
+ BeanUtils.copyProperties(param, fsCourseWatchLog);
|
|
|
|
+ fsCourseWatchLog.setSendType(1);
|
|
|
|
+ fsCourseWatchLog.setDuration(0L);
|
|
|
|
+ fsCourseWatchLog.setCreateTime(new Date());
|
|
|
|
+ fsCourseWatchLog.setLogType(1);
|
|
|
|
+ courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
|
|
|
|
+ String redisKey = "h5wxuser:watch:heartbeat:" + param.getUserId() + ":" + param.getVideoId() + ":" + 0;
|
|
|
|
+ redisCache.setCacheObject(redisKey, LocalDateTime.now().toString());
|
|
|
|
+ // 设置 Redis 记录的过期时间(例如 5 分钟)
|
|
|
|
+ redisCache.expire(redisKey, 300, TimeUnit.SECONDS);
|
|
|
|
+ }
|
|
|
|
+ return ResponseResult.ok(Boolean.TRUE);
|
|
|
|
+ }
|
|
//判断该销售是否存在
|
|
//判断该销售是否存在
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
if (companyUser == null){
|
|
if (companyUser == null){
|
|
@@ -1791,7 +1864,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
if (param.getLinkType() != null && param.getLinkType() == 1){
|
|
if (param.getLinkType() != null && param.getLinkType() == 1){
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if (param.getCompanyUserId()==null){
|
|
|
|
+ param.setCompanyUserId(0L);
|
|
|
|
+ }
|
|
// 从Redis中获取观看时长
|
|
// 从Redis中获取观看时长
|
|
String redisKey = "h5wxuser:watch:duration:" + param.getUserId() + ":" + param.getVideoId() + ":" + param.getCompanyUserId();
|
|
String redisKey = "h5wxuser:watch:duration:" + param.getUserId() + ":" + param.getVideoId() + ":" + param.getCompanyUserId();
|
|
log.info("看课redis缓存key:{}", redisKey);
|
|
log.info("看课redis缓存key:{}", redisKey);
|