xiaoyong931011
2022-12-02 be3f0d8e8616f37621b3e969d6ca269ddf58a3a2
20221130
7 files modified
61 ■■■■ changed files
src/main/java/cc/mrbird/febs/dapp/chain/ChainEnum.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/chain/EthService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/mapper/DappFundFlowDao.java 4 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java 19 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java 2 ●●● patch | view | raw | blame | history
src/main/resources/mapper/dapp/DappFundFlowDao.xml 15 ●●●●● patch | view | raw | blame | history
src/test/java/cc/mrbird/febs/MemberTest.java 15 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/dapp/chain/ChainEnum.java
@@ -24,6 +24,11 @@
            "https://bsc-dataseed1.ninicoin.io",
            "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
            ""),
    BNB("BSC", "0xBa6206B3Be305278Ea65bA54C4E6188B252AEc4a",
            "0x1bc264d17bd2b1f3c0480764272284b8e6c8b0a39a590c26940f84f7b090cc74",
            "https://bsc-dataseed1.ninicoin.io",
            "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
            ""),
    /**
     * 币安链 代币合约
src/main/java/cc/mrbird/febs/dapp/chain/EthService.java
@@ -257,6 +257,7 @@
    public String tokenTransfer(String privateKey, String fromAddress, String toAddress, String amount) throws ExecutionException, InterruptedException {
        String gas = getGas();
//        String gas = "5";
        BigDecimal amountPow = new BigDecimal(amount).multiply(BigDecimal.TEN.pow(decimals()));
        amount = amountPow.toPlainString();
src/main/java/cc/mrbird/febs/dapp/mapper/DappFundFlowDao.java
@@ -28,4 +28,8 @@
    DappFundFlowEntity selectNewestFundFlow(@Param("memberId") Long memberId, @Param("type") Integer type);
    BigDecimal selectSumAmountByMemberIdAndTypeAndStatus(@Param("memberId") Long memberId,@Param("type")int type, @Param("status")int status);
    DappFundFlowEntity selectInfoById(@Param("id")Long id);
    int updateStatusById(@Param("status")int status, @Param("id")Long id);
}
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -450,20 +450,22 @@
    public void bnbTransfer(Long id) {
        log.info("{}",id);
        //获取对应的流水记录
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id);
        DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(id);
        if(ObjectUtil.isEmpty(dappFundFlowEntity)){
            return;
        }
        if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == dappFundFlowEntity.getStatus()){
            return;
        }
        Long memberId = dappFundFlowEntity.getMemberId();
        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
        if(ObjectUtil.isEmpty(dappMemberEntity)){
            return;
        }
        Integer count = dappFundFlowDao.updateStatusById(DappFundFlowEntity.WITHDRAW_STATUS_AGREE,dappFundFlowEntity.getId());
//        if(count > 0){
//        //金额
//        BigDecimal amount = dappFundFlowEntity.getAmount();
//        Long memberId = dappFundFlowEntity.getMemberId();
//        DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId);
//        if(ObjectUtil.isEmpty(dappMemberEntity)){
//            return;
//        }
//        //目标地址
//        String address = dappMemberEntity.getAddress();
//        String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount);
@@ -471,9 +473,8 @@
//            return;
//        }
//        dappFundFlowEntity.setToHash(hash);
        dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE);
        dappFundFlowDao.updateById(dappFundFlowEntity);
//        dappFundFlowDao.updateById(dappFundFlowEntity);
//        }
    }
    @Override
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -193,7 +193,7 @@
                }
                //插入一条会员入列记录,即加入动能队列
                DappSystemProfit dappSystemProfit = new DappSystemProfit(member.getId(), transferDto.getAmount());
                DappSystemProfit dappSystemProfit = new DappSystemProfit(member.getId(), flow.getAmount());
                dappSystemProfitDao.insert(dappSystemProfit);
                flow.setFromHash(transferDto.getTxHash());
src/main/resources/mapper/dapp/DappFundFlowDao.xml
@@ -88,4 +88,19 @@
          and type = #{type}
        and status = #{status}
    </select>
    <select id="selectInfoById" resultType="cc.mrbird.febs.dapp.entity.DappFundFlowEntity">
        select a.* from dapp_fund_flow
        where a.id = #{id}
          for update
    </select>
    <update id="updateStatusById">
        update dapp_fund_flow
        set status = #{status},
            version = version + 1
    where id = #{id}
        and version = 1
        and status = 1
    </update>
</mapper>
src/test/java/cc/mrbird/febs/MemberTest.java
@@ -3,8 +3,10 @@
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.dapp.chain.ChainEnum;
import cc.mrbird.febs.dapp.chain.ChainService;
import cc.mrbird.febs.dapp.entity.DappFundFlowEntity;
import cc.mrbird.febs.dapp.entity.DappMemberEntity;
import cc.mrbird.febs.dapp.entity.DataDictionaryCustom;
import cc.mrbird.febs.dapp.mapper.DappFundFlowDao;
import cc.mrbird.febs.dapp.mapper.DappMemberDao;
import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
import cn.hutool.core.util.StrUtil;
@@ -28,6 +30,9 @@
    @Autowired
    private DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @Autowired
    private DappFundFlowDao dappFundFlowDao;
    //        String address = dappMemberEntity.getAddress();
//        String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount);
//        if(StrUtil.isEmpty(hash)){
@@ -37,10 +42,12 @@
    public void tranfer(){
        String address = "0xD9076245473060DDa1a65f5f3D89a4D0598995E6";
        BigDecimal amount = new BigDecimal("0.0009");
        String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount);
        if(StrUtil.isEmpty(hash)){
            return;
        }
        String hash = ChainService.getInstance(ChainEnum.BNB.name()).transfer(address, amount);
////        if(StrUtil.isEmpty(hash)){
////            return;
////        }
//        BigDecimal balance = ChainService.getInstance(ChainEnum.WBNB.name()).balanceOf(ChainEnum.WBNB.getAddress());
//        Integer count = dappFundFlowDao.updateStatusById(DappFundFlowEntity.WITHDRAW_STATUS_AGREE,464L);
        System.out.println(hash);
    }