|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据绑定用户编号,获得下级用户编号列表
|
|
|
|
|