| | |
| | | package cc.mrbird.febs.rabbit.consumer; |
| | | |
| | | import cc.mrbird.febs.dapp.entity.DbMemberNode; |
| | | import cc.mrbird.febs.dapp.mapper.DbMemberNodeMapper; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.rabbit.QueueConstants; |
| | | import com.rabbitmq.client.Channel; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | |
| | | @Autowired |
| | | private DappSystemService dappSystemService; |
| | | |
| | | // @RabbitListener(queues = QueueConstants.ONLINE_TRANSFER) |
| | | // public void onlineTransfer(String batchNo) { |
| | | // log.info("收到链上转账消息:{}", batchNo); |
| | | // dappSystemService.onlineTransfer(batchNo); |
| | | // } |
| | | // |
| | | // @RabbitListener(queues = QueueConstants.DISTRIB_PROFIT) |
| | | // public void distrbProfit(String id) { |
| | | // log.info("收到滑点分配消息:{}", id); |
| | | // dappSystemService.tradeNftProfitDistribute(Long.parseLong(id)); |
| | | // } |
| | | // |
| | | // @RabbitListener(queues = QueueConstants.USER_BUY_REWARD) |
| | | // public void userBuyReward(String id) { |
| | | // log.info("收到用户购买奖励消息:{}", id); |
| | | // dappSystemService.userBuyReward(Long.parseLong(id)); |
| | | // } |
| | | // |
| | | // @RabbitListener(queues = QueueConstants.NFT_BOX) |
| | | // public void nftBox(String id) { |
| | | // log.info("收到nft盲盒消息:{}", id); |
| | | // dappSystemService.boxCnt(Long.parseLong(id)); |
| | | // } |
| | | @Autowired |
| | | private DbMemberNodeMapper dbMemberNodeMapper; |
| | | |
| | | @RabbitListener(queues = QueueConstants.ACHIEVE_TREE) |
| | | public void achieveTree(String id) { |
| | |
| | | */ |
| | | @RabbitListener(queues = QueueConstants.TFC_NEW_PRICE) |
| | | public void tfcNewPrice(String data) { |
| | | dappSystemService.tfcNewPrice(data); |
| | | // dappSystemService.tfcNewPrice(data); |
| | | } |
| | | |
| | | /** |
| | | * @param data |
| | | */ |
| | | @RabbitListener(queues = QueueConstants.DISTRIB_PROFIT) |
| | | public void feeDistribute(String data) { |
| | | dappSystemService.feeDistribute(data); |
| | | } |
| | | |
| | | |
| | | |
| | | @RabbitListener(queues = QueueConstants.TFC_INVITE_PERK_QUEEN) |
| | | public void invitePerkMsg(Long id) { |
| | | log.info("消费推荐规则奖励,流水ID:{}", id); |
| | | dappSystemService.invitePerkMsg(id); |
| | | } |
| | | |
| | | @RabbitListener(queues = QueueConstants.TFC_NODE_PERK_QUEEN) |
| | | public void nodePerkMsg(Long id) { |
| | | log.info("消费节点投资,流水ID:{}", id); |
| | | dappSystemService.nodePerkMsg(id); |
| | | } |
| | | |
| | | @RabbitListener(queues = QueueConstants.TFC_NODE_AGAIN) |
| | | public void nodeMsg(Long id) { |
| | | log.info("复投:{}", id); |
| | | dappSystemService.achieveTreeV2(id); |
| | | } |
| | | |
| | | @RabbitListener(queues = QueueConstants.TFC_NODE_AGAIN_LONG) |
| | | public void nodeMsgLong(Long id) { |
| | | log.info("复投:{}", id); |
| | | |
| | | /** |
| | | * 获取所有左右节点都有值,轮数为 1,未复投work_state = 1 的节点 |
| | | * 判断右节点有值 |
| | | * 有继续向判断右节点 |
| | | * 有,原纪录复投逻辑 |
| | | */ |
| | | QueryWrapper<DbMemberNode> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("count_fund", 1); |
| | | objectQueryWrapper.eq("work_state", 1); |
| | | objectQueryWrapper.eq("type", 1); |
| | | objectQueryWrapper.eq("member_id", id); |
| | | List<DbMemberNode> dbMemberNodes = dbMemberNodeMapper.selectList(objectQueryWrapper); |
| | | if(CollUtil.isEmpty(dbMemberNodes)){ |
| | | return; |
| | | } |
| | | for(DbMemberNode dbMemberNode : dbMemberNodes){ |
| | | if(ObjectUtil.isEmpty(dbMemberNode.getRightNode())){ |
| | | continue; |
| | | } |
| | | //子节点 |
| | | Long rightNode = dbMemberNode.getRightNode(); |
| | | DbMemberNode dbMemberNode1 = dbMemberNodeMapper.selectById(rightNode); |
| | | if(ObjectUtil.isEmpty(dbMemberNode1)){ |
| | | continue; |
| | | } |
| | | |
| | | if(ObjectUtil.isEmpty(dbMemberNode1.getRightNode())){ |
| | | continue; |
| | | } |
| | | |
| | | //有,则上级节点出局复投,轮数加1,复投逻辑 |
| | | dappSystemService.memberNodeNext(dbMemberNode); |
| | | } |
| | | } |
| | | } |