| | |
| | | package cc.mrbird.febs.dapp.mapper; |
| | | |
| | | import cc.mrbird.febs.dapp.dto.TeamListDto; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.vo.TeamListVo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | void updateMemberActiveStatus(@Param("accountStatus")int i, @Param("id")Long id); |
| | | |
| | | List<DappMemberEntity> selectMemberInfoByRefererId(@Param("refererId")String inviteId); |
| | | |
| | | Integer selectCountByAccountTypeAndRefererId(@Param("accountType")String code, @Param("refererId")String inviteId); |
| | | } |
| | |
| | | void memberOut(Long id); |
| | | //转账拨币 |
| | | void bnbTransfer(Long id); |
| | | |
| | | void agentUp(String inviteId); |
| | | } |
| | |
| | | import cc.mrbird.febs.dapp.vo.AdminSystemFeeVo; |
| | | import cc.mrbird.febs.dapp.vo.ApiRunListInfoVo; |
| | | import cc.mrbird.febs.dapp.vo.TeamListVo; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cc.mrbird.febs.system.entity.User; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | private final DappAchieveMemberTreeDao dappAchieveMemberTreeDao; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final DappSystemProfitDao dappSystemProfitDao; |
| | | private final ChainProducer chainProducer; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | connectDto.setInviteId(null); |
| | | } |
| | | member = insertMember(connectDto.getAddress(), connectDto.getInviteId()); |
| | | //升级用户的代理等级 |
| | | chainProducer.sendAgentUpMsg(connectDto.getInviteId()); |
| | | } |
| | | |
| | | String key = LoginUserUtil.getLoginKey(connectDto.getAddress(), connectDto.getNonce(), connectDto.getSign()); |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void agentUp(String inviteId) { |
| | | //根据邀请码获取用户信息 |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return; |
| | | } |
| | | String accountType = dappMemberEntity.getAccountType(); |
| | | if(DataDictionaryEnum.BIG_BOSS.getCode().equals(accountType)){ |
| | | return; |
| | | } |
| | | //当前为BOSS,且直推中有两个BOSS以上,则升级BIG_BOSS |
| | | if(DataDictionaryEnum.BOSS.getCode().equals(accountType)){ |
| | | Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(DataDictionaryEnum.BOSS.getCode(),inviteId); |
| | | if(2 <= bossCount){ |
| | | dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BIG_BOSS.getCode(),dappMemberEntity.getId()); |
| | | } |
| | | } |
| | | //当前为AGENT,且直推中有两个以上,则升级BOSS |
| | | if(DataDictionaryEnum.AGENT.getCode().equals(accountType)){ |
| | | Integer bossCount = dappMemberDao.selectCountByAccountTypeAndRefererId(null,inviteId); |
| | | if(2 <= bossCount){ |
| | | dappMemberDao.updateMemberAccountType(DataDictionaryEnum.BOSS.getCode(),dappMemberEntity.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String refererIds = "1,2,3,4,5," + |
| | | "6,7,8,9,10," + |
| | |
| | | **/ |
| | | public class QueueConstants { |
| | | |
| | | public static final String QUEUE_BNB_AGENT_UP = "queue_bnb_agent_up"; |
| | | public static final String QUEUE_BNB_TRANSFER = "queue_bnb_transfer"; |
| | | public static final String QUEUE_MEMBER_OUT = "queue_bnb_member_out"; |
| | | public static final String QUEUE_LEVEL_PROFIT = "queue_bnb_level_profit_transfer"; |
| | |
| | | |
| | | @Getter |
| | | public enum QueueEnum { |
| | | //代理升级 |
| | | BNB_AGENT_UP("exchange_bnb_agent_up", "route_key_bnb_agent_up", "queue_bnb_agent_up"), |
| | | //转账拨币 |
| | | BNB_TRANSFER("exchange_bnb_transfer", "route_key_bnb_transfer", "queue_bnb_transfer"), |
| | | //计算是否有人出局 |
| | |
| | | return BindingBuilder.bind(bnbTransferQueue()).to(bnbTransferExchange()).with(QueueEnum.BNB_TRANSFER.getRoute()); |
| | | } |
| | | // === 转账拨币 end === |
| | | |
| | | |
| | | |
| | | // === 代理升级 start === |
| | | @Bean |
| | | public DirectExchange agentUpExchange() { |
| | | return new DirectExchange(QueueEnum.BNB_AGENT_UP.getExchange()); |
| | | } |
| | | |
| | | @Bean |
| | | public Queue agentUpQueue() { |
| | | return new Queue(QueueEnum.BNB_AGENT_UP.getQueue()); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding agentUpBind() { |
| | | return BindingBuilder.bind(agentUpQueue()).to(agentUpExchange()).with(QueueEnum.BNB_AGENT_UP.getRoute()); |
| | | } |
| | | // === 代理升级 end === |
| | | } |
| | |
| | | log.info("消费转账拨币:{}", id); |
| | | dappSystemService.bnbTransfer(id); |
| | | } |
| | | |
| | | /**代理升级 |
| | | * @param inviteId |
| | | */ |
| | | @RabbitListener(queues = QueueConstants.QUEUE_BNB_AGENT_UP) |
| | | public void agentUp(String inviteId) { |
| | | log.info("代理升级:{}", inviteId); |
| | | dappSystemService.agentUp(inviteId); |
| | | } |
| | | } |
| | |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.BNB_TRANSFER.getExchange(), QueueEnum.BNB_TRANSFER.getRoute(), id, correlationData); |
| | | } |
| | | |
| | | /** |
| | | * 代理升级 |
| | | */ |
| | | public void sendAgentUpMsg(String inviteId) { |
| | | log.info("代理升级:{}", inviteId); |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.BNB_AGENT_UP.getExchange(), QueueEnum.BNB_AGENT_UP.getRoute(), inviteId, correlationData); |
| | | } |
| | | } |
| | |
| | | from dapp_member a |
| | | where referer_id = #{refererId} |
| | | </select> |
| | | |
| | | <select id="selectCountByAccountTypeAndRefererId" resultType="java.lang.Integer"> |
| | | select count(id) |
| | | from dapp_member |
| | | <where> |
| | | referer_id = #{refererId} |
| | | <if test="code != null"> |
| | | and account_type = @{code} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |