|  | @@ -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;
 | 
	
	
		
			
				|  | @@ -107,7 +108,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 | 
	
		
			
				|  |  |      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
 | 
	
	
		
			
				|  | @@ -1189,21 +1191,25 @@ 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){
 | 
	
		
			
				|  |  | +                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());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //判断服务号配置是否存在
 | 
	
	
		
			
				|  | @@ -1517,14 +1523,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){
 | 
	
	
		
			
				|  | @@ -1564,7 +1562,15 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 | 
	
		
			
				|  |  |          //3、以上都不是,则标识重粉,需要加入关系表,并打上重粉标签
 | 
	
		
			
				|  |  |          FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(fsUser.getUserId(), param.getProjectId());
 | 
	
		
			
				|  |  |          if(Objects.isNull(userCompanyUser)) {
 | 
	
		
			
				|  |  | -            return ResponseResult.fail(BizResponseEnum.DATA_NOT_EXIST, getCompanyUserQRCode(companyUser));
 | 
	
		
			
				|  |  | +            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(), param.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 逻辑调整:如果会员已经绑定了销售,直接提示,不添加重粉数据了-2025年6月16日14点53分
 |