From 749aa3a368c3c6b23671f715fa6c17cf0d4db932 Mon Sep 17 00:00:00 2001
From: zhangshengli <1810377322@163.com>
Date: Thu, 11 Jul 2024 14:11:33 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E4=BA=BA=E5=88=86=E9=94=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../brokerage/BrokerageUserServiceImpl.java | 33 ++++++++++---------
.../yudao-module-member-biz/pom.xml | 6 ++++
.../vo/AppAuthWeixinMiniAppLoginReqVO.java | 5 +++
.../service/auth/MemberAuthServiceImpl.java | 12 +++++++
.../yudao-module-system-biz/pom.xml | 6 ++++
.../service/social/SocialUserServiceImpl.java | 5 +++
6 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
index ff958a8..c6b77de 100644
--- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
+++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.BooleanUtil;
+import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
@@ -91,7 +92,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
}
// 情况二:修改推广员
- validateCanBindUser(brokerageUser, bindUserId);
+ //validateCanBindUser(brokerageUser, bindUserId);
brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(id)));
}
@@ -296,27 +297,29 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
private void validateCanBindUser(BrokerageUserDO user, Long bindUserId) {
// 校验要绑定的用户有无推广资格
BrokerageUserDO bindUser = brokerageUserMapper.selectById(bindUserId);
- if (bindUser == null || BooleanUtil.isFalse(bindUser.getBrokerageEnabled())) {
+ /*if (bindUser == null || BooleanUtil.isFalse(bindUser.getBrokerageEnabled())) {
throw exception(BROKERAGE_BIND_USER_NOT_ENABLED);
- }
+ }*/
// 校验绑定自己
- if (Objects.equals(user.getId(), bindUserId)) {
+ /* if (Objects.equals(user.getId(), bindUserId)) {
throw exception(BROKERAGE_BIND_SELF);
+ }*/
+if(ObjectUtil.isNotEmpty(bindUser)){
+ // 下级不能绑定自己的上级
+ for (int i = 0; i <= Short.MAX_VALUE; i++) {
+ if (Objects.equals(bindUser.getBindUserId(), user.getId())) {
+ throw exception(BROKERAGE_BIND_LOOP);
}
-
- // 下级不能绑定自己的上级
- for (int i = 0; i <= Short.MAX_VALUE; i++) {
- if (Objects.equals(bindUser.getBindUserId(), user.getId())) {
- throw exception(BROKERAGE_BIND_LOOP);
- }
- bindUser = getBrokerageUser(bindUser.getBindUserId());
- // 找到根节点,结束循环
- if (bindUser == null || bindUser.getBindUserId() == null) {
- break;
- }
+ bindUser = getBrokerageUser(bindUser.getBindUserId());
+ // 找到根节点,结束循环
+ if (bindUser == null || bindUser.getBindUserId() == null) {
+ break;
}
}
+}
+
+ }
/**
* 根据绑定用户编号,获得下级用户编号列表
diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/pom.xml b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/pom.xml
index 3c9b81e..1a38c75 100644
--- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/pom.xml
+++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/pom.xml
@@ -85,6 +85,12 @@
cn.iocoder.boot
yudao-spring-boot-starter-biz-ip
+
+ cn.iocoder.boot
+ yudao-module-trade-biz
+ 2.1.0-jdk8-snapshot
+ compile
+
diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java
index b14f182..5c14883 100644
--- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java
+++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/vo/AppAuthWeixinMiniAppLoginReqVO.java
@@ -27,4 +27,9 @@ public class AppAuthWeixinMiniAppLoginReqVO {
@NotEmpty(message = "state 不能为空")
private String state;
+
+
+ @Schema(description = "bindUserId")
+ private Long bindUserId;
+
}
diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java
index e1a8ec5..0e6fb58 100644
--- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java
+++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.service.auth;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
@@ -27,6 +28,7 @@ import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum;
import cn.iocoder.yudao.module.system.enums.oauth2.OAuth2ClientConstants;
import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum;
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -61,6 +63,9 @@ public class MemberAuthServiceImpl implements MemberAuthService {
@Resource
private OAuth2TokenApi oauth2TokenApi;
+ @Resource
+ private BrokerageUserService brokerageUserService;
+
@Override
public AppAuthLoginRespVO login(AppAuthLoginReqVO reqVO) {
// 使用手机 + 密码,进行登录。
@@ -149,6 +154,13 @@ public class MemberAuthServiceImpl implements MemberAuthService {
String openid = socialUserApi.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(),
SocialTypeEnum.WECHAT_MINI_APP.getType(), reqVO.getLoginCode(), reqVO.getState()));
+ if( ObjectUtil.isNotEmpty(reqVO.getBindUserId())){
+ brokerageUserService.bindBrokerageUser(user.getId(), reqVO.getBindUserId());
+
+ }else {
+ brokerageUserService.bindBrokerageUser(user.getId(), 0L);
+ }
+ //绑定分销用户
// 创建 Token 令牌,记录登录日志
return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, openid);
}
diff --git a/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/pom.xml b/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/pom.xml
index 6de1a58..0b87984 100644
--- a/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/pom.xml
+++ b/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/pom.xml
@@ -127,6 +127,12 @@
com.xingyuv
spring-boot-starter-captcha-plus
+
+ cn.iocoder.boot
+ yudao-module-trade-biz
+ 2.1.0-jdk8-snapshot
+ compile
+
diff --git a/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java
index 7458d9c..d95254b 100644
--- a/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java
+++ b/ruoyi-vue-pro-master/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java
@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper;
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserMapper;
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
+import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageUserService;
import com.xingyuv.jushauth.model.AuthUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -46,6 +47,8 @@ public class SocialUserServiceImpl implements SocialUserService {
@Resource
private SocialClientService socialClientService;
+
+
@Override
public List getSocialUserList(Long userId, Integer userType) {
// 获得绑定
@@ -77,6 +80,8 @@ public class SocialUserServiceImpl implements SocialUserService {
.userId(reqDTO.getUserId()).userType(reqDTO.getUserType())
.socialUserId(socialUser.getId()).socialType(socialUser.getType()).build();
socialUserBindMapper.insert(socialUserBind);
+ //创建绑定用户
+
return socialUser.getOpenid();
}