升级帮扶员,帮扶人

main
13233904609 4 months ago
parent 98e2ad606e
commit c8e5b0a10c

@ -59,4 +59,8 @@ public class BrokerageUserDO extends BaseDO {
*
*/
private Integer frozenPrice;
/**
*
*/
private Integer level;
}

@ -25,6 +25,9 @@ import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;
@ -74,6 +77,9 @@ public class MemberUserServiceImpl implements MemberUserService {
@Resource
private MemberLevelMapper memberLevelMapper;
@Resource
private BrokerageUserMapper brokerageUserMapper;
@Override
public MemberUserDO getUserByMobile(String mobile) {
return memberUserMapper.selectByMobile(mobile);
@ -336,6 +342,10 @@ public class MemberUserServiceImpl implements MemberUserService {
.setId(userId)
.setLevelId(memberLevelDO.getId())
);
brokerageUserMapper.updateById(new BrokerageUserDO()
.setId(userId)
.setLevel(1)
);
if(i>0){
return true;
}
@ -353,14 +363,122 @@ public class MemberUserServiceImpl implements MemberUserService {
}
//先会员本身升级为帮扶员
int i = memberUserMapper.updateById(new MemberUserDO()
.setId(userId)
.setLevelId(levelList.get(0).getId())
);
// if(i>0){
// return true;
// }
return false;
}
private void recursionMemberLevel(List<MemberLevelDO> levelList,Long userId){
private void recursionMemberLevel(Long userId){
//查询会员信息
MemberUserDO memberUserDO = memberUserMapper.selectById(userId);
//查询会员当前等级
MemberLevelDO memberLevelDO = memberLevelMapper.selectById(memberUserDO.getLevelId());
if(ObjectUtil.isNotEmpty(memberLevelDO)){
//查询上一级会员等级
MemberLevelDO upLevelDO = memberLevelMapper.selectOne(new LambdaQueryWrapperX<MemberLevelDO>()
.eq(MemberLevelDO::getStatus, 0)
.eq(MemberLevelDO::getDeleted, 0)
.eq(MemberLevelDO::getLevel, (memberLevelDO.getLevel()+1))
.orderByAsc(MemberLevelDO::getLevel));
if(ObjectUtil.isNotEmpty(upLevelDO)){
if(ObjectUtil.equal(memberLevelDO.getLevel(),1)){//帮扶人升级帮扶员
//添加分润
//升级会员
//修改会员等级
memberUserMapper.updateById(new MemberUserDO()
.setId(userId)
.setLevelId(upLevelDO.getId())
);
//修改邀请记录等级
brokerageUserMapper.updateById(new BrokerageUserDO()
.setId(userId)
.setLevel(upLevelDO.getLevel())
);
//判断上级会员是否升级
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId);
recursionMemberLevel(brokerageUserDO.getBindUserId());
}
if(ObjectUtil.equal(memberLevelDO.getLevel(),2)){//帮扶员升级帮扶大使
//查询会员邀请记录下级会员
List<BrokerageUserDO> brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>()
.eq(BrokerageUserDO::getBindUserId, userId)
.eq(BrokerageUserDO::getLevel, memberLevelDO.getLevel())
.eq(BrokerageUserDO::getDeleted, 0)
);
if(ObjectUtil.isNotEmpty(brokerageUserDOS)){
if(brokerageUserDOS.size()>=3){
//升级会员
memberUserMapper.updateById(new MemberUserDO()
.setId(userId)
.setLevelId(upLevelDO.getId())
);
brokerageUserMapper.updateById(new BrokerageUserDO()
.setId(userId)
.setLevel(upLevelDO.getLevel())
);
}
}
//判断上级会员是否升级
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId);
recursionMemberLevel(brokerageUserDO.getBindUserId());
}
if(ObjectUtil.equal(memberLevelDO.getLevel(),3)){//帮扶大使升级帮扶中心
//查询会员邀请记录下级会员
List<BrokerageUserDO> brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>()
.eq(BrokerageUserDO::getBindUserId, userId)
.eq(BrokerageUserDO::getLevel, memberLevelDO.getLevel())
.eq(BrokerageUserDO::getDeleted, 0)
);
if(ObjectUtil.isNotEmpty(brokerageUserDOS)){
if(brokerageUserDOS.size()>=5){
//升级会员
memberUserMapper.updateById(new MemberUserDO()
.setId(userId)
.setLevelId(upLevelDO.getId())
);
brokerageUserMapper.updateById(new BrokerageUserDO()
.setId(userId)
.setLevel(upLevelDO.getLevel())
);
}
}
//判断上级会员是否升级
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId);
recursionMemberLevel(brokerageUserDO.getBindUserId());
}
if(ObjectUtil.equal(memberLevelDO.getLevel(),4)){//帮扶中心升级帮扶驿站
//查询会员邀请记录下级会员
List<BrokerageUserDO> brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX<BrokerageUserDO>()
.eq(BrokerageUserDO::getBindUserId, userId)
.eq(BrokerageUserDO::getLevel, memberLevelDO.getLevel())
.eq(BrokerageUserDO::getDeleted, 0)
);
if(ObjectUtil.isNotEmpty(brokerageUserDOS)){
if(brokerageUserDOS.size()>=10){
//升级会员
memberUserMapper.updateById(new MemberUserDO()
.setId(userId)
.setLevelId(upLevelDO.getId())
);
brokerageUserMapper.updateById(new BrokerageUserDO()
.setId(userId)
.setLevel(upLevelDO.getLevel())
);
}
}
//判断上级会员是否升级
BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId);
recursionMemberLevel(brokerageUserDO.getBindUserId());
}
if(ObjectUtil.equal(memberLevelDO.getLevel(),5)){//帮扶驿站---最终级别
}
}
}
}
}

Loading…
Cancel
Save