|
|
@@ -296,7 +296,7 @@ public class DistributeServiceImpl implements DistributeService {
|
|
|
handlerSpecialEquipmentRate(userDistributeReq.getEpRate(), userDistribute);
|
|
|
|
|
|
//下级渠道绑定
|
|
|
- handlerDistributeSub(userDistributeReq.getUserDistributeSubs(), userDistribute);
|
|
|
+ handlerDistributeSub(userDistributeReq.getUserDistributeSub(), userDistribute);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -545,21 +545,36 @@ public class DistributeServiceImpl implements DistributeService {
|
|
|
/**
|
|
|
* 下级渠道
|
|
|
*/
|
|
|
- private void handlerDistributeSub(List<UserDistributeSub> userDistributeSubs, UserDistribute userDistribute) {
|
|
|
- if (CollUtil.isNotEmpty(userDistributeSubs)) {
|
|
|
- Long distributeId = userDistribute.getId();
|
|
|
- userDistributeSubs.forEach(sub -> {
|
|
|
- sub.setDistributeId(distributeId);
|
|
|
- sub.setUserId(userDistribute.getUserId());
|
|
|
- if (sub.getId() == null) {
|
|
|
- try {
|
|
|
- userDistributeSubMapper.insert(sub);
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
- }
|
|
|
- } else {
|
|
|
- userDistributeSubMapper.updateById(sub);
|
|
|
+ private void handlerDistributeSub(UserDistributeSub userDistributeSub, UserDistribute userDistribute) {
|
|
|
+ if (userDistributeSub != null) {
|
|
|
+ userDistributeSub.setSubUserId(userDistribute.getUserId());
|
|
|
+ if (userDistributeSub.getUserId() == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请选择对应的上级渠道..");
|
|
|
+ }
|
|
|
+ if (userDistributeSub.getUserId().equals(userDistribute.getUserId())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("不能选择自己作为上级渠道");
|
|
|
+ }
|
|
|
+ UserDistribute superUser = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class)
|
|
|
+ .eq(UserDistribute::getUserId, userDistributeSub.getUserId())
|
|
|
+ .eq(UserDistribute::getDeleted, 1));
|
|
|
+ if (superUser == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("上级渠道不存在");
|
|
|
+ }
|
|
|
+ userDistributeSub.setDistributeId(superUser.getId());
|
|
|
+ if (userDistributeSub.getId() == null) {
|
|
|
+ try {
|
|
|
+ userDistributeSubMapper.insert(userDistributeSub);
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
}
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ userDistributeSubMapper.updateById(userDistributeSub);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (userDistributeSubMapper.selectCount(Wrappers.lambdaQuery(UserDistributeSub.class)
|
|
|
+ .eq(UserDistributeSub::getSubUserId, userDistribute.getUserId()))>0) {
|
|
|
+ userDistributeSubMapper.delete(Wrappers.lambdaQuery(UserDistributeSub.class)
|
|
|
+ .eq(UserDistributeSub::getSubUserId, userDistribute.getUserId()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|