|
@@ -22,6 +22,7 @@ import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyMapper;
|
|
|
import com.fs.company.mapper.CompanyMoneyLogsMapper;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
+import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.*;
|
|
|
import com.fs.course.dto.CoursePackageDTO;
|
|
@@ -100,14 +101,16 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
{
|
|
|
@Value("${cloud_host.company_name}")
|
|
|
private String signProjectName;
|
|
|
-
|
|
|
+ @Value("${isNewWxMerchant}")
|
|
|
+ private Boolean isNewWxMerchant;
|
|
|
private static final Logger logger = LoggerFactory.getLogger(FsUserCourseVideoServiceImpl.class);
|
|
|
|
|
|
|
|
|
private static final String miniappRealLink = "/pages_course/video.html?course=";
|
|
|
private static final String REAL_LINK_PREFIX = "/courseH5/pages/course/learning?course=";
|
|
|
private static final String SHORT_LINK_PREFIX = "/courseH5/pages/course/learning?s=";
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ ICompanyService companyService;
|
|
|
@Autowired
|
|
|
private CompanyMoneyLogsMapper moneyLogsMapper;
|
|
|
@Autowired
|
|
@@ -265,6 +268,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
fsUserCourseVideo.setListingStartTime(null);
|
|
|
fsUserCourseVideo.setListingEndTime(null);
|
|
|
}
|
|
|
+ String videoRedisKey = "h5user:video:duration:" + fsUserCourseVideo.getVideoId();
|
|
|
+ redisCache.setCacheObject(videoRedisKey, fsUserCourseVideo.getDuration());
|
|
|
return fsUserCourseVideoMapper.updateFsUserCourseVideo(fsUserCourseVideo);
|
|
|
}
|
|
|
|
|
@@ -920,6 +925,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 积分奖励
|
|
|
case 2:
|
|
|
return sendIntegralReward(param,user, log, config);
|
|
|
+ // 红包+积分
|
|
|
+ case 3:
|
|
|
+ R sendRed = sendRedPacketReward(param, user, log, video, config);
|
|
|
+ if (!Objects.equals(sendRed.get("code"), 200)) {
|
|
|
+ return sendRed;
|
|
|
+ }
|
|
|
+ return sendIntegralReward(param,user, log, config);
|
|
|
default:
|
|
|
return R.error("参数错误!");
|
|
|
}
|
|
@@ -979,6 +991,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 积分奖励
|
|
|
case 2:
|
|
|
return sendIntegralReward(param,user, log, config);
|
|
|
+ // 红包+积分
|
|
|
+ case 3:
|
|
|
+ R sendRed = sendRedPacketReward(param, user, log, video, config);
|
|
|
+ if (!Objects.equals(sendRed.get("code"), 200)) {
|
|
|
+ return sendRed;
|
|
|
+ }
|
|
|
+ return sendIntegralReward(param,user, log, config);
|
|
|
default:
|
|
|
return R.error("参数错误!");
|
|
|
}
|
|
@@ -1189,27 +1208,32 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// if (company.getCourseMiniAppId()==null){
|
|
|
// return R.error("销售公司参数错误,未绑定小程序");
|
|
|
// }
|
|
|
- FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
|
- 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());
|
|
|
- }catch (Exception e){
|
|
|
- logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(),e);
|
|
|
- }
|
|
|
-
|
|
|
+ if (user.getMpOpenId()!=null&&!isNewWxMerchant){
|
|
|
+ packetParam.setOpenId(user.getMpOpenId());
|
|
|
}else {
|
|
|
- packetParam.setOpenId(fsUserWx.getOpenId());
|
|
|
+ FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
|
|
|
+ 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());
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("zyp \n 【更新或插入用户与小程序的绑定关系失败】:{}", user.getUserId(),e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ packetParam.setOpenId(fsUserWx.getOpenId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//判断服务号配置是否存在
|
|
|
if (StringUtils.isNotEmpty(config.getMpAppId())){
|
|
|
packetParam.setMpAppId(config.getMpAppId());
|
|
|
}
|
|
|
+ //组装发红包数据
|
|
|
packetParam.setAmount(amount);
|
|
|
packetParam.setSource(param.getSource());
|
|
|
packetParam.setRedPacketMode(config.getRedPacketMode());
|
|
@@ -1225,6 +1249,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
//2025.6.19 红包金额为0的时候
|
|
|
if (amount.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
|
+ Company company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
+ BigDecimal money = company.getMoney();
|
|
|
+ if (money.compareTo(BigDecimal.ZERO)<0) {
|
|
|
+ return R.error("服务商余额不足,请联系群主服务器充值!");
|
|
|
+ }
|
|
|
// 发送红包
|
|
|
R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
@@ -1516,14 +1545,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
public ResponseResult<FsUser> isAddCompanyUser(FsUserCourseAddCompanyUserParam param) {
|
|
|
logger.info("\n 【进入个微-判断是否添加客服】,入参:{}",param);
|
|
|
|
|
|
- // 生成锁的key,使用用户ID和视频ID组合
|
|
|
- String lockKey = "submit:lock:" + param.getUserId() + ":" + param.getVideoId();
|
|
|
- // 尝试获取锁,3秒过期
|
|
|
- boolean locked = redisCache.setIfAbsent(lockKey, "1", 1, TimeUnit.SECONDS);
|
|
|
-
|
|
|
- if (!locked) {
|
|
|
- return ResponseResult.fail(504, "请勿重复提交,请等待3秒后重试");
|
|
|
- }
|
|
|
//查询用户
|
|
|
FsUser fsUser = fsUserMapper.selectFsUserById(param.getUserId());
|
|
|
if (fsUser == null){
|
|
@@ -1558,12 +1579,31 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return ResponseResult.fail(405,"当前销售不存在");
|
|
|
}
|
|
|
|
|
|
- //判断:1、如果没有绑定销售,就返回给客服的微信图片;
|
|
|
- //2、如果只绑定了当前销售,需要添加看课记录(正常流程);
|
|
|
- //3、以上都不是,则标识重粉,需要加入关系表,并打上重粉标签
|
|
|
- FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(fsUser.getUserId(), param.getProjectId());
|
|
|
+ // 获取课程所属项目id
|
|
|
+ FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
+ Long courseProject = fsUserCourse.getProject();
|
|
|
+ if(Objects.isNull(courseProject)){
|
|
|
+ return ResponseResult.fail(504, "课程配置错误,项目归属为空,课程ID: " + param.getCourseId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询【用户-项目】关系
|
|
|
+ FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(fsUser.getUserId(), courseProject);
|
|
|
+
|
|
|
+ // 添加逻辑:如果存在fs_user表数据,但是又不存在fs_user_company_user表,则表示是以前企微看课的,需要手动绑定
|
|
|
if(Objects.isNull(userCompanyUser)) {
|
|
|
- return ResponseResult.fail(BizResponseEnum.DATA_NOT_EXIST, getCompanyUserQRCode(companyUser));
|
|
|
+ if(fsUser.getCompanyUserId() == null && fsUser.getIsAddQw() == 1){
|
|
|
+ userCompanyUser = userCompanyUserService.bindRelationship(fsUser.getUserId(), courseProject, param.getCompanyId(), param.getCompanyUserId(), 1);
|
|
|
+ }else {
|
|
|
+ Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
|
+ if((companyUser.getIsAllowedAllRegister() !=null && companyUser.getIsAllowedAllRegister() != 1)){
|
|
|
+ return ResponseResult.fail(504,"当前销售禁止绑定会员,请联系销售!");
|
|
|
+ }
|
|
|
+ if (companyUser.getIsNeedRegisterMember() == null || companyUser.getIsNeedRegisterMember() == 1){
|
|
|
+ return ResponseResult.fail(504,"请联系销售发送邀请链接成为会员!");
|
|
|
+ }
|
|
|
+ int defaultStatus = (company != null ? company.getFsUserIsDefaultBlack() : 0) == 1 ? 0 : 1;
|
|
|
+ userCompanyUser = userCompanyUserService.bindRelationship(param.getUserId(), courseProject, companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 逻辑调整:如果会员已经绑定了销售,直接提示,不添加重粉数据了-2025年6月16日14点53分
|
|
@@ -1588,25 +1628,16 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
//查询看课记录
|
|
|
// FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getWatchCourseVideoByFsUser(param.getUserId(), param.getVideoId(), param.getCompanyUserId());
|
|
|
FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getCourseWatchLogByUser(param.getUserId(), param.getVideoId());
|
|
|
- // 获取课程所属项目id
|
|
|
- FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
- Long courseProject = null;
|
|
|
- if(fsUserCourse != null){
|
|
|
- courseProject = fsUserCourse.getProject();
|
|
|
- }
|
|
|
-
|
|
|
- // 项目校验
|
|
|
- if (Objects.isNull(courseProject) || !courseProject.equals(param.getProjectId())) {
|
|
|
- return ResponseResult.fail(504, "课程项目不匹配");
|
|
|
- }
|
|
|
|
|
|
if (!isUserCoursePeriodValid(param)) {
|
|
|
return ResponseResult.fail(504, "请观看最新的课程项目");
|
|
|
}
|
|
|
// 项目看课数限制
|
|
|
- Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), param.getProjectId());
|
|
|
- if (Objects.isNull(watchCourseVideo) && logCount > 0) {
|
|
|
- return ResponseResult.fail(504, "超过项目看课数量限制");
|
|
|
+ if(!"福本源".equals(signProjectName) && !"宽益堂".equals(signProjectName)) {
|
|
|
+ Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), courseProject);
|
|
|
+ if (Objects.isNull(watchCourseVideo) && logCount > 0) {
|
|
|
+ return ResponseResult.fail(504, "超过项目看课数量限制");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
|
|
@@ -1834,6 +1865,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
vo.setPlayDuration(duration);
|
|
|
//判断营期的课程状态是否是进行中
|
|
|
if(param.getId() != null){
|
|
|
+
|
|
|
FsUserCoursePeriodDays days = fsUserCoursePeriodDaysMapper.selectById(param.getId());
|
|
|
|
|
|
// 查询销售设置的看课时间
|