From c8e5b0a10c07f532ace1a8808ded1c49dd2bf189 Mon Sep 17 00:00:00 2001 From: 13233904609 <13233904609@163.cm> Date: Sat, 13 Jul 2024 09:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=B8=AE=E6=89=B6=E5=91=98?= =?UTF-8?q?=EF=BC=8C=E5=B8=AE=E6=89=B6=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataobject/brokerage/BrokerageUserDO.java | 4 + .../service/user/MemberUserServiceImpl.java | 124 +++++++++++++++++- 2 files changed, 125 insertions(+), 3 deletions(-) diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java index 8d73858..1be8990 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/BrokerageUserDO.java @@ -59,4 +59,8 @@ public class BrokerageUserDO extends BaseDO { * 冻结佣金 */ private Integer frozenPrice; + /** + * 会员等级 + */ + private Integer level; } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index 93c59f4..4d41544 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -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 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() + .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 brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() + .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 brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() + .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 brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() + .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)){//帮扶驿站---最终级别 + + } + } + } } - }