Browse Source

1、调整项目id绑定销售

yfh 1 week ago
parent
commit
481ad320da

+ 30 - 24
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -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分

+ 13 - 21
fs-user-app/src/main/java/com/fs/app/controller/WxH5MpController.java

@@ -103,26 +103,22 @@ public class WxH5MpController {
             WxOAuth2UserInfo wxMpUser = wxMpService.getOAuth2Service().getUserInfo(wxMpOAuth2AccessToken, null);
 
 
-            //临时的手动和自动 融合
-            if (param.getProjectId() == null || param.getProjectId() == 0L) {
+            // 处理用户信息
+            FsUser user = processUserInfo(wxMpUser, company,companyUser,param);
+
+            // 检查用户是否已绑定其他销售
+            FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(user.getUserId(), param.getProjectId());
+            if (Objects.nonNull(userCompanyUser) && !param.getCompanyUserId().equals(userCompanyUser.getCompanyUserId())){
+                return R.error(500, "该用户("+user.getUserId() + ")已成为其他销售会员");
+            }
 
-                // 处理用户信息
-                FsUser user = processUserInfoByCourseLoginByMp(wxMpUser);
-                // 生成token并返回结果
-                return generateLoginResult(user);
+//            // 处理用户与公司的关系
+//            processUserCompanyRelationship(user, param, companyUser, company);
 
-            }else {
-                // 处理用户信息
-                FsUser user = processUserInfo(wxMpUser, company,companyUser,param);
 
-                // 检查用户是否已绑定其他销售
-                FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(user.getUserId(), param.getProjectId());
-                if (Objects.nonNull(userCompanyUser) && !param.getCompanyUserId().equals(userCompanyUser.getCompanyUserId())){
-                    return R.error(500, "该用户("+user.getUserId() + ")已成为其他销售会员");
-                }
 
-                return generateLoginResult(user);
-            }
+            // 生成token并返回结果
+            return generateLoginResult(user);
 
 
         } catch (WxErrorException e) {
@@ -197,11 +193,7 @@ public class WxH5MpController {
             newUser.setCreateTime(new Date());
             newUser.setStatus(company != null && company.getFsUserIsDefaultBlack() == 1 ? 0 : 1);
             userService.insertFsUser(newUser);
-            if((companyUser.getIsAllowedAllRegister() == null || companyUser.getIsAllowedAllRegister() == 1)
-                    && companyUser.getIsNeedRegisterMember() != null && companyUser.getIsNeedRegisterMember() != 1){
-                int defaultStatus = (company != null ? company.getFsUserIsDefaultBlack() : 0) == 1 ? 0 : 1;
-                userCompanyUserService.bindRelationship(newUser.getUserId(), param.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
-            }
+
             return newUser;
         }
     }

+ 5 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/IndexScrmController.java

@@ -16,6 +16,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -120,7 +121,10 @@ public class IndexScrmController extends AppBaseController {
 		map.setIsDel(0);
 		map.setType(1);
 		List<FsStoreCanvasScrm> canvas=storeCanvasService.selectFsStoreCanvasList(map);
-		return R.ok().put("data", canvas.get(0));
+		if (CollectionUtils.isNotEmpty(canvas)){
+			return R.ok().put("data", canvas.get(0));
+		}
+		return R.ok();
 	}