src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java
@@ -96,4 +96,23 @@ } // end // start @Bean public DirectExchange chargeExchange() { return new DirectExchange(RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE_BALANCE.getExchange()); } @Bean public Queue chargeQueue() { return new Queue(RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE_BALANCE.getQueue()); } @Bean public Binding chargeBind() { return BindingBuilder.bind(chargeQueue()).to(chargeExchange()).with(RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE_BALANCE.getRoute()); } // end } src/main/java/cc/mrbird/febs/common/enumerates/RunVipMoneyFlowTypeEnum.java
@@ -8,6 +8,11 @@ /** * 碳币兑换USDT */ COMMISSION_PAY_CHARGE(18,"USDT充值:{}","USDT充值"), /** * 碳币兑换USDT */ COMMISSION_PAY_GROW(17,"升级权益,余额支付{}","升级权益,余额支付"), /** src/main/java/cc/mrbird/febs/mall/chain/ercCoin/BscUsdtContractEvent.java
@@ -85,8 +85,12 @@ MallCharge mallCharge = mallCharges.get(0); mallCharge.setState(YesOrNoEnum.YES.getValue()); mallChargeMapper.updateById(mallCharge); agentProducer.sendBuyVipSuccessMsg(mallCharge.getId()); if(StrUtil.isNotEmpty(mallCharge.getVipCode())){ agentProducer.sendBuyVipSuccessMsg(mallCharge.getId()); }else{ agentProducer.sendChargeSuccessMsg(mallCharge.getId()); } log.info("扫描到用户ID:{},地址:{},充值金额:{}",mallCharge.getMemberId(),fromAddress,amount); src/main/java/cc/mrbird/febs/mall/chain/trcCoin/quartz/ChainTrcListenerJob.java
@@ -141,7 +141,12 @@ MallCharge mallCharge = mallCharges.get(0); mallCharge.setState(YesOrNoEnum.YES.getValue()); mallChargeMapper.updateById(mallCharge); if(StrUtil.isNotEmpty(mallCharge.getVipCode())){ agentProducer.sendBuyVipSuccessMsg(mallCharge.getId()); }else{ agentProducer.sendChargeSuccessMsg(mallCharge.getId()); } log.info("扫描到用户ID:{},地址:{},充值金额:{}", mallCharge.getMemberId(), fromAddress, amount); } src/main/java/cc/mrbird/febs/mall/controller/ApiRunVipController.java
@@ -133,4 +133,24 @@ public FebsResponse goChargeInfo(@RequestBody @Valid ApiGoChargeInfoDto apiGoChargeInfoDto) { return iRunVipService.goChargeInfo(apiGoChargeInfoDto); } @ApiOperation(value = "【充值USDT】立即购买", notes = "【充值USDT】立即购买") @ApiResponses({ @ApiResponse(code = 200, message = "success", response = ApiGoChargeVo.class) }) @PostMapping(value = "/goChargeUSDT") @SubmitRepeat public FebsResponse goChargeUSDT(@RequestBody @Valid ApiGoChargeUSDTDto apiGoChargeDto) { return iRunVipService.goChargeUSDT(apiGoChargeDto); } @ApiOperation(value = "【充值USDT】马上支付", notes = "【充值USDT】马上支付") @ApiResponses({ @ApiResponse(code = 200, message = "success", response = ApiGoChargeVo.class) }) @PostMapping(value = "/goChargeUSDTInfo") @SubmitRepeat public FebsResponse goChargeUSDTInfo(@RequestBody @Valid ApiGoChargeInfoDto apiGoChargeInfoDto) { return iRunVipService.goChargeUSDTInfo(apiGoChargeInfoDto); } } src/main/java/cc/mrbird/febs/mall/dto/ApiGoChargeUSDTDto.java
New file @@ -0,0 +1,27 @@ package cc.mrbird.febs.mall.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import java.math.BigDecimal; @Data @ApiModel(value = "ApiGoChargeUSDTDto", description = "API信息参数接收类") public class ApiGoChargeUSDTDto { @NotNull(message = "请选择地址") @ApiModelProperty(value = "地址ID", example = "123456") private Long addressId; @NotNull(message = "请选择金额") @Min(0) @ApiModelProperty(value = "数量", example = "123456") private BigDecimal amount; @NotNull(message = "请输入资金密码") @ApiModelProperty(value = "资金密码", example = "123456") private String tradeWord; } src/main/java/cc/mrbird/febs/mall/service/IAgentService.java
@@ -15,4 +15,6 @@ void buyVipSuccessMsg(Long chargeId); void nodeUpMsg(Long memberId); void chargeSuccessMsg(Long chargeId); } src/main/java/cc/mrbird/febs/mall/service/IRunVipService.java
@@ -32,4 +32,8 @@ FebsResponse growCharge(ApiGrowChargeDto apiGrowChargeDto); FebsResponse reduceAmount(); FebsResponse goChargeUSDT(ApiGoChargeUSDTDto apiGoChargeDto); FebsResponse goChargeUSDTInfo(ApiGoChargeInfoDto apiGoChargeInfoDto); } src/main/java/cc/mrbird/febs/mall/service/impl/AdminRunVipServiceImpl.java
@@ -11,6 +11,7 @@ import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; import cc.mrbird.febs.rabbit.producter.AgentProducer; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -88,8 +89,13 @@ mallChargeMapper.updateById(mallCharge); if(mallCharge.getState() == YesOrNoEnum.YES.getValue()){ if(StrUtil.isNotEmpty(mallCharge.getVipCode())){ agentProducer.sendBuyVipSuccessMsg(mallCharge.getId()); }else{ agentProducer.sendChargeSuccessMsg(mallCharge.getId()); } } return new FebsResponse().success().message("操作成功"); } src/main/java/cc/mrbird/febs/mall/service/impl/AgentServiceImpl.java
@@ -1,15 +1,11 @@ package cc.mrbird.febs.mall.service.impl; import cc.mrbird.febs.common.enumerates.AgentLevelEnum; import cc.mrbird.febs.common.enumerates.RunVipDataDictionaryEnum; import cc.mrbird.febs.common.enumerates.YesOrNoEnum; import cc.mrbird.febs.common.enumerates.*; import cc.mrbird.febs.common.utils.MallUtils; import cc.mrbird.febs.mall.dto.ApiMemberChargeFailDto; import cc.mrbird.febs.mall.entity.*; import cc.mrbird.febs.mall.mapper.*; import cc.mrbird.febs.mall.service.AsyncService; import cc.mrbird.febs.mall.service.IAgentService; import cc.mrbird.febs.mall.service.IApiMallMemberService; import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; import cc.mrbird.febs.mall.service.*; import cc.mrbird.febs.rabbit.producter.AgentProducer; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; @@ -46,6 +42,7 @@ private final RunNodeSetMapper runNodeSetMapper; private final AsyncService asyncService; private final RunVipGrowMapper runVipGrowMapper; private final IMallMoneyFlowService mallMoneyFlowService; @Override @Transactional(rollbackFor = Exception.class) @@ -399,4 +396,28 @@ MallMember graMember = mallMemberMapper.selectInfoByInviteId(parentMember.getReferrerId()); NodeUp(graMember.getId(),directCnt,teamCnt,achieveCnt); } @Override public void chargeSuccessMsg(Long chargeId) { MallCharge mallCharge = mallChargeMapper.selectById(chargeId); if(null == mallCharge){ return; } Long memberId = mallCharge.getMemberId(); BigDecimal amount = mallCharge.getAmount(); walletService.addCommission(amount, memberId); String orderNo = MallUtils.getOrderNum("C"); mallMoneyFlowService.runVipMoneyFlowAdd( memberId, memberId, orderNo, FlowTypeEnum.COMMISSION.getValue(), RunVipMoneyFlowTypeEnum.COMMISSION_PAY_CHARGE.getValue(), amount, StrUtil.format(RunVipMoneyFlowTypeEnum.COMMISSION_PAY_CHARGE.getDescription(),amount), YesOrNoEnum.YES.getValue() ); } } src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java
@@ -1,10 +1,7 @@ package cc.mrbird.febs.mall.service.impl; import cc.mrbird.febs.common.entity.FebsResponse; import cc.mrbird.febs.common.enumerates.FlowTypeEnum; import cc.mrbird.febs.common.enumerates.RunVipDataDictionaryEnum; import cc.mrbird.febs.common.enumerates.RunVipMoneyFlowTypeEnum; import cc.mrbird.febs.common.enumerates.YesOrNoEnum; import cc.mrbird.febs.common.enumerates.*; import cc.mrbird.febs.common.exception.FebsException; import cc.mrbird.febs.common.utils.LoginUserUtil; import cc.mrbird.febs.common.utils.MallUtils; @@ -702,4 +699,107 @@ apiReduceAmountVo.setReduceAmount(reduceAmount); return new FebsResponse().success().data(apiReduceAmountVo); } @Override public FebsResponse goChargeUSDT(ApiGoChargeUSDTDto apiGoChargeDto) { Long memberId = LoginUserUtil.getLoginUser().getId(); ApiGoChargeVo apiGoChargeVo = new ApiGoChargeVo(); BigDecimal amount = apiGoChargeDto.getAmount(); if(BigDecimal.ZERO.compareTo(amount) >= 0){ throw new FebsException("金额异常"); } MallMember mallMember = mallMemberMapper.selectById(memberId); if (StrUtil.isBlank(mallMember.getTradePassword())) { throw new FebsException("未设置资金密码"); } if (!mallMember.getTradePassword().equals(SecureUtil.md5(apiGoChargeDto.getTradeWord()))) { throw new FebsException("资金密码错误"); } Long addressId = apiGoChargeDto.getAddressId(); MallMemberPayment mallMemberPayment = mallMemberPaymentMapper.selectById(addressId); if(ObjectUtil.isEmpty(mallMemberPayment)){ return new FebsResponse().fail().message("请先绑定你的地址"); } //判断系统的充值地址 String trcType = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( RunVipDataDictionaryEnum.CHARGE_TYPE_TRC.getType(), RunVipDataDictionaryEnum.CHARGE_TYPE_TRC.getCode() ).getValue(); String sysAddress = ""; if(trcType.equals(mallMemberPayment.getBankNo())){ sysAddress = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_TRC.getType(), RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_TRC.getCode() ).getValue(); }else{ sysAddress = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_BSC.getType(), RunVipDataDictionaryEnum.CHARGE_SYS_ADDRESS_BSC.getCode() ).getValue(); } String failMinutes = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( RunVipDataDictionaryEnum.CHARGE_SYS_FAIL_TIME.getType(), RunVipDataDictionaryEnum.CHARGE_SYS_FAIL_TIME.getCode() ).getValue(); DateTime failTime = DateUtil.offsetMinute(DateUtil.date(), Integer.parseInt(failMinutes)); MallCharge mallCharge = new MallCharge(); String orderNo = MallUtils.getOrderNum("C"); mallCharge.setMemberId(memberId); mallCharge.setOrderNo(orderNo); mallCharge.setState(YesOrNoEnum.ING.getValue()); mallCharge.setType(mallMemberPayment.getBankNo()); mallCharge.setAddress(mallMemberPayment.getBank()); mallCharge.setFailTime(failTime); mallCharge.setSysAddress(sysAddress); mallCharge.setAmount(amount); mallCharge.setVipName(RunVipMoneyFlowTypeEnum.COMMISSION_PAY_CHARGE.getTypeDec()); mallChargeMapper.insert(mallCharge); apiGoChargeVo.setFailTime(mallCharge.getFailTime()); apiGoChargeVo.setAddress(mallCharge.getAddress()); apiGoChargeVo.setAmount(mallCharge.getAmount()); apiGoChargeVo.setSysAddress(mallCharge.getSysAddress()); apiGoChargeVo.setSysAddressType(mallCharge.getType()); /** * 充值接口调用后,发送一个延时队列 * 功能:延迟时间为【failMinutes】后,更新充值记录为失败。 */ ApiMemberChargeFailDto apiMemberChargeFailDto = new ApiMemberChargeFailDto(); apiMemberChargeFailDto.setChargeId(mallCharge.getId()); apiMemberChargeFailDto.setFailTime(Integer.parseInt(failMinutes) * 60L* 1000L); agentProducer.sendMemberChargeFailMsg(apiMemberChargeFailDto); return new FebsResponse().success().data(apiGoChargeVo); } @Override public FebsResponse goChargeUSDTInfo(ApiGoChargeInfoDto apiGoChargeInfoDto) { Long memberId = LoginUserUtil.getLoginUser().getId(); String orderNo = apiGoChargeInfoDto.getOrderNo(); LambdaQueryWrapper<MallCharge> objectLambdaQueryWrapper = new LambdaQueryWrapper<>(); objectLambdaQueryWrapper.eq(MallCharge::getMemberId,memberId); objectLambdaQueryWrapper.eq(MallCharge::getOrderNo,orderNo); MallCharge mallCharge = mallChargeMapper.selectOne(objectLambdaQueryWrapper); ApiGoChargeVo apiGoChargeVo = new ApiGoChargeVo(); if(null == mallCharge){ throw new FebsException("记录不存在"); } apiGoChargeVo.setFailTime(mallCharge.getFailTime()); apiGoChargeVo.setAddress(mallCharge.getAddress()); apiGoChargeVo.setAmount(mallCharge.getAmount()); apiGoChargeVo.setSysAddress(mallCharge.getSysAddress()); apiGoChargeVo.setSysAddressType(mallCharge.getType()); return new FebsResponse().success().data(apiGoChargeVo); } } src/main/java/cc/mrbird/febs/rabbit/constants/ExchangeConstants.java
@@ -9,5 +9,6 @@ public static final String RUN_VIP_OPERATION_CHARGE_FAIL_TTL = "exchange_run_vip_operation_charge_fail_tll"; public static final String RUN_VIP_OPERATION_CHARGE_FAIL = "exchange_run_vip_operation_charge_fail"; public static final String RUN_VIP_OPERATION_CHARGE = "exchange_run_vip_operation_charge"; public static final String RUN_VIP_OPERATION_CHARGE_BALANCE = "exchange_run_vip_operation_charge_balance"; public static final String RUN_VIP_NODE_UP = "exchange_run_vip_node_up"; } src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java
@@ -7,6 +7,7 @@ public class QueueConstants { public static final String RUN_VIP_NODE_UP = "queue_run_vip_node_up"; public static final String RUN_VIP_OPERATION_CHARGE_BALANCE = "queue_run_vip_operation_charge_balance"; public static final String RUN_VIP_OPERATION_CHARGE = "queue_run_vip_operation_charge"; public static final String RUN_VIP_OPERATION_CHARGE_FAIL = "queue_run_vip_operation_charge_fail"; public static final String RUN_VIP_OPERATION_CHARGE_FAIL_TTL = "queue_run_vip_operation_charge_fail_tll"; src/main/java/cc/mrbird/febs/rabbit/constants/RouteKeyConstants.java
@@ -6,6 +6,7 @@ **/ public class RouteKeyConstants { public static final String RUN_VIP_NODE_UP = "route_key_run_vip_node_up"; public static final String RUN_VIP_OPERATION_CHARGE_BALANCE = "route_key_run_vip_operation_charge_balance"; public static final String RUN_VIP_OPERATION_CHARGE = "route_key_run_vip_operation_charge"; public static final String RUN_VIP_OPERATION_CHARGE_FAIL = "route_key_run_vip_operation_charge_fail"; public static final String RUN_VIP_OPERATION_CHARGE_FAIL_TTL = "route_key_run_vip_operation_charge_fail_tll"; src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java
@@ -48,6 +48,19 @@ /** * 充值成功 */ @RabbitListener(queues = QueueConstants.RUN_VIP_OPERATION_CHARGE_BALANCE) public void chargeSuccessMsg(Long chargeId) { try { agentService.chargeSuccessMsg(chargeId); } catch (Exception e) { log.error("消费充值异常", e); } } /** * 节点升级 */ @RabbitListener(queues = QueueConstants.RUN_VIP_NODE_UP) src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java
@@ -16,6 +16,13 @@ QueueConstants.RUN_VIP_NODE_UP), /** * 充值成功消息 */ RUN_VIP_OPERATION_CHARGE_BALANCE(ExchangeConstants.RUN_VIP_OPERATION_CHARGE_BALANCE, RouteKeyConstants.RUN_VIP_OPERATION_CHARGE_BALANCE, QueueConstants.RUN_VIP_OPERATION_CHARGE_BALANCE), /** * 购买成功消息 */ RUN_VIP_OPERATION_CHARGE(ExchangeConstants.RUN_VIP_OPERATION_CHARGE, src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java
@@ -68,6 +68,14 @@ id); } public void sendChargeSuccessMsg(Long id) { log.info("发送充值成功消息:{}",id); rabbitTemplate.convertAndSend( RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE_BALANCE.getExchange(), RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE_BALANCE.getRoute(), id); } public void sendNodeUpMsg(Long memberId) { log.info("发送节点升级消息:{}",memberId); rabbitTemplate.convertAndSend(