| | |
| | | package cc.mrbird.febs.dapp.controller; |
| | | |
| | | import cc.mrbird.febs.common.annotation.ControllerEndpoint; |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.utils.FebsUtil; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.dto.BatchTransferDto; |
| | | import cc.mrbird.febs.dapp.entity.DappAccountMoneyChangeEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappAchieve; |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.service.AsyncCjService; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.system.entity.User; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | public class MemberMoneyFlowController extends BaseController { |
| | | |
| | | private final DappWalletService dappWalletService; |
| | | private final DappFundFlowDao dappFundFlowDao; |
| | | private final DappMemberDao dappMemberDao; |
| | | private final AsyncCjService asyncCjService; |
| | | |
| | | @GetMapping("/dappAchieveItem") |
| | | public FebsResponse dappAchieveItem(QueryRequest request, DappAchieve dappAchieve, Integer parentId) { |
| | |
| | | return new FebsResponse().success().data(getDataTable(dappWalletService.fundFlowInPage(dappFundFlowEntity, request))); |
| | | } |
| | | |
| | | @GetMapping("confirmOrder") |
| | | @ControllerEndpoint(operation = "批量转账", exceptionMessage = "操作失败") |
| | | public FebsResponse confirmOrder(DappFundFlowEntity dappFundFlowIn){ |
| | | String orderIds = dappFundFlowIn.getOrderIds(); |
| | | List<String> ids = StrUtil.splitTrim(orderIds, ","); |
| | | Integer type = 0; |
| | | List<BatchTransferDto> batchTransferDtos = new ArrayList<>(); |
| | | for(String id : ids){ |
| | | long orderId = Long.parseLong(id); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(orderId); |
| | | if(1 != dappFundFlowEntity.getStatus()){ |
| | | continue; |
| | | } |
| | | BigDecimal amount = dappFundFlowEntity.getAmount().negate(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >=0){ |
| | | amount = amount.negate(); |
| | | } |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | batchTransferDtos.add(new BatchTransferDto(dappMemberEntity.getAddress(), amount)); |
| | | |
| | | dappFundFlowEntity.setStatus(2); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | type = dappFundFlowEntity.getType(); |
| | | } |
| | | if(CollUtil.isNotEmpty(batchTransferDtos)){ |
| | | if(FlowTypeEnum.USDT_OUT.getValue() == type){ |
| | | ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferList(batchTransferDtos); |
| | | }else if(FlowTypeEnum.DAI_BI_OUT.getValue() == type){ |
| | | ChainService.getInstance(ChainEnum.BSC_GFA.name()).transferList(batchTransferDtos); |
| | | } |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("confirmOrderV2") |
| | | @ControllerEndpoint(operation = "批量转账", exceptionMessage = "操作失败") |
| | | public FebsResponse confirmOrderV2(DappFundFlowEntity dappFundFlowIn){ |
| | | String orderIds = dappFundFlowIn.getOrderIds(); |
| | | List<String> ids = StrUtil.splitTrim(orderIds, ","); |
| | | for(String id : ids){ |
| | | long orderId = Long.parseLong(id); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(orderId); |
| | | if(1 != dappFundFlowEntity.getStatus()){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(2000); |
| | | asyncCjService.confirmOrder(dappFundFlowEntity); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("confirmCancel") |
| | | @ControllerEndpoint(operation = "取消", exceptionMessage = "操作失败") |
| | | public FebsResponse confirmCancel(DappFundFlowEntity dappFundFlowIn){ |
| | | String orderIds = dappFundFlowIn.getOrderIds(); |
| | | List<String> ids = StrUtil.splitTrim(orderIds, ","); |
| | | for(String id : ids){ |
| | | long orderId = Long.parseLong(id); |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(orderId); |
| | | if(1 != dappFundFlowEntity.getStatus()){ |
| | | continue; |
| | | } |
| | | asyncCjService.confirmCancel(dappFundFlowEntity); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @PostMapping(value = "/withdrawAgree/{id}") |
| | | public FebsResponse withdrawAgree(@PathVariable("id") Long id) { |
| | | dappWalletService.withdrawAgreeOrNot(id, 1); |