diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/feign/YyyyfMoneyFeign.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/feign/YyyyfMoneyFeign.java index df84375..e2bb4b1 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/feign/YyyyfMoneyFeign.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/feign/YyyyfMoneyFeign.java @@ -17,6 +17,6 @@ import java.math.BigDecimal; @FeignClient("dapp-yyyf-server") public interface YyyyfMoneyFeign { - @GetMapping("/yyyfMoney/resetDigitWallet") - ResultDTO resetDigitWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance); + @GetMapping("/yyyfMoney/resetWallet") + ResultDTO resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance); } diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java index c615117..d739989 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletServiceImpl.java @@ -216,7 +216,7 @@ public class BtcWalletServiceImpl implements BtcWalletService { throw new BtcException(BtcEnums.RESET_ERROR); } YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate); - ResultDTO resultDTO = yyyyfMoneyFeign.resetDigitWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance())); + ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance())); if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){ btcWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(), userOpenId, tokenId, walletType, new Date()); diff --git a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java index dc7dda7..4b11f64 100644 --- a/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java +++ b/blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/service/impl/BtcWalletTransferServiceImpl.java @@ -1,6 +1,7 @@ package com.blockchain.server.btc.service.impl; import com.blockchain.common.base.dto.GasDTO; +import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.WalletChangeDTO; import com.blockchain.common.base.dto.WalletOrderDTO; import com.blockchain.server.btc.common.constants.BtcTransferConstans; @@ -11,12 +12,13 @@ import com.blockchain.server.btc.dto.BtcWalletDTO; import com.blockchain.server.btc.dto.BtcWalletTransferDTO; import com.blockchain.server.btc.entity.BtcWalletTransfer; import com.blockchain.server.btc.feign.EthServerFegin; +import com.blockchain.server.btc.feign.YyyyfMoneyFeign; import com.blockchain.server.btc.mapper.BtcWalletTransferMapper; import com.blockchain.server.btc.service.*; import com.codingapi.tx.annotation.ITxTransaction; import com.codingapi.tx.annotation.TxTransaction; -import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; @@ -46,6 +48,12 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I @Autowired private EthServerFegin ethServerFegin; + @Autowired + RedisTemplate redisTemplate; + + @Autowired + private YyyyfMoneyFeign yyyyfMoneyFeign; + @Override public Integer insertTransfer(BtcWalletTransfer btcWalletTransfer) { return btcWalletTransferMapper.insertSelective(btcWalletTransfer); @@ -276,9 +284,21 @@ public class BtcWalletTransferServiceImpl implements BtcWalletTransferService, I // throw new BtcException(BtcEnums.WITHDRAW_ERROR); // } // } + btcWalletDTO= null; + String coinName="BTC"; + if(tokenId==1){ + coinName="USDT"; + } + ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(toAddress, coinName,BigDecimal.valueOf( amount)); + + if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){ + btcWalletDTO=btcWalletService.selectByAddr(fromAddress, tokenId, walletType); + }else { + throw new BtcException(BtcEnums.WITHDRAW_ERROR); + } //返回加减余额后的数据 - return btcWalletService.selectByAddr(fromAddress, tokenId, walletType); + return btcWalletDTO; } /*@Override diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/feign/YyyyfMoneyFeign.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/feign/YyyyfMoneyFeign.java index f1e04a4..2be8fa4 100644 --- a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/feign/YyyyfMoneyFeign.java +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/feign/YyyyfMoneyFeign.java @@ -17,6 +17,6 @@ import java.math.BigDecimal; @FeignClient("dapp-yyyf-server") public interface YyyyfMoneyFeign { - @GetMapping("/yyyfMoney/resetDigitWallet") - ResultDTO resetDigitWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance); + @GetMapping("/yyyfMoney/resetWallet") + ResultDTO resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance); } diff --git a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java index c295f59..ac9edbe 100644 --- a/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java +++ b/blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/service/impl/EosWalletServiceImpl.java @@ -135,7 +135,15 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction { walletTransfer.setTransferType(EosConstant.TransferType.TRANSFER_OUT); walletTransfer.setStatus(EosConstant.TransferStatus.SUCCESS); walletTransfer.setTimestamp(now); - return eosWalletTransferService.insertWalletTransfer(walletTransfer); + + ResultDTO yyyfResultDTO = yyyyfMoneyFeign.resetWallet(account, "EOS", amount); + int result=0; + if(yyyfResultDTO.getCode()==200 && yyyfResultDTO.getData().booleanValue()){ + result= eosWalletTransferService.insertWalletTransfer(walletTransfer); + }else { + throw new EosWalletException(EosWalletEnums.FREEBALANCE_NOT_ENOUGH); + } + return result; } @@ -393,7 +401,7 @@ public class EosWalletServiceImpl implements EosWalletService, ITxTransaction { throw new EosWalletException(EosWalletEnums.RESET_ERROR); } YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate); - ResultDTO resultDTO = yyyyfMoneyFeign.resetDigitWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance())); + ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance())); if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){ // 修改钱包插入充值记录 walletMapper.updateWalletBalanceByUserOpenId(config.getBalance(), userOpenId, tokenId, walletType, new Date()); diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/feign/YyyyfMoneyFeign.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/feign/YyyyfMoneyFeign.java index 7d305bf..7b64d5d 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/feign/YyyyfMoneyFeign.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/feign/YyyyfMoneyFeign.java @@ -17,6 +17,6 @@ import java.math.BigDecimal; @FeignClient("dapp-yyyf-server") public interface YyyyfMoneyFeign { - @GetMapping("/yyyfMoney/resetDigitWallet") - ResultDTO resetDigitWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance); + @GetMapping("/yyyfMoney/resetWallet") + ResultDTO resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance); } diff --git a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java index f0b83d0..c06b6c5 100644 --- a/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java +++ b/blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/service/impl/EthWalletServiceImpl.java @@ -334,6 +334,12 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction { // EthWalletConstants.TransferType.OUT, EthWalletConstants.StatusType.OUT_LOAD1, date); // } // } + ResultDTO resultDTO= yyyyfMoneyFeign.resetWallet(toAddr,"ETH",BigDecimal.valueOf(Double.valueOf(amount))); + + if(resultDTO.getCode()!=200 || !resultDTO.getData().booleanValue()){ + throw new EthWalletException(EthWalletEnums.FREEBALANCE_NOT_ENOUGH); + } + return tx; } @@ -439,7 +445,7 @@ public class EthWalletServiceImpl implements IEthWalletService, ITxTransaction { throw new EthWalletException(EthWalletEnums.RESET_ERROR); } YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userOpenId, redisTemplate); - ResultDTO resultDTO = yyyyfMoneyFeign.resetDigitWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance())); + ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), tokenId, BigDecimal.ZERO.subtract(config.getBalance())); if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()){ ethWalletMapper.updateWalletBalanceByUserOpenId(config.getBalance(),userOpenId,tokenId,walletType,new Date()); diff --git a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/feign/YyyyfMoneyFeign.java b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/feign/YyyyfMoneyFeign.java index fd12e37..749d03d 100644 --- a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/feign/YyyyfMoneyFeign.java +++ b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/feign/YyyyfMoneyFeign.java @@ -18,7 +18,5 @@ import java.math.BigDecimal; public interface YyyyfMoneyFeign { @GetMapping("/yyyfMoney/resetWallet") - ResultDTO resetWallet(@RequestParam("assessUserId") String assessUserId, - @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance, - @RequestParam("String")String payType, @RequestParam("payMoney")BigDecimal payMoney); + ResultDTO resetWallet(@RequestParam("assessUserId") String assessUserId, @RequestParam("coinName") String coinName, @RequestParam("balance") BigDecimal balance); } diff --git a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/OrderServiceImpl.java b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/OrderServiceImpl.java index 18615ce..66f9458 100644 --- a/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/OrderServiceImpl.java +++ b/blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/OrderServiceImpl.java @@ -289,7 +289,7 @@ public class OrderServiceImpl implements OrderService, ITxTransaction { YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userId, redisTemplate); - ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), order.getCoinName(),order.getAmount(),payType,BigDecimal.ZERO.subtract(order.getTurnover())); + ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), payType,BigDecimal.ZERO.subtract(order.getTurnover())); if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()) { @@ -327,7 +327,7 @@ public class OrderServiceImpl implements OrderService, ITxTransaction { YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userId, redisTemplate); - ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), order.getCoinName(),BigDecimal.ZERO.subtract(order.getAmount()),order.getOrderPayType(),order.getTurnover()); + ResultDTO resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(),order.getOrderPayType(),order.getTurnover()); if(resultDTO.getCode()==200 && resultDTO.getData().booleanValue()) { diff --git a/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml b/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml index 2ce250b..edf2f92 100644 --- a/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml +++ b/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml @@ -1,5 +1,7 @@ server: port: 8101 + servlet: + context-path: /user #注册中心 eureka: client: diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java index d8510b0..c24e7c0 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/YyyfMoneyController.java @@ -48,19 +48,19 @@ public class YyyfMoneyController { - @PostMapping("/resetDigitWallet") - @ApiOperation(value = YyyfMoneyApi.ResetDigitWallet.METHOD_NAME, - notes = YyyfMoneyApi.ResetDigitWallet.METHOD_NOTE) - public ResultDTO resetDigitWallet(@ApiParam(YyyfMoneyApi.ResetDigitWallet.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId",required =true) String assessUserId, - @ApiParam(YyyfMoneyApi.ResetDigitWallet.METHOD_COIN_NAME) @RequestParam(name = "coinName",required =true)String coinName, - @ApiParam(YyyfMoneyApi.ResetDigitWallet.METHOD_BALANCE) @RequestParam(name = "balance",required =true) BigDecimal balance) { + @PostMapping("/resetWallet") + @ApiOperation(value = YyyfMoneyApi.ResetWallet.METHOD_NAME, + notes = YyyfMoneyApi.ResetWallet.METHOD_NOTE) + public ResultDTO resetDigitWallet(@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId",required =true) String assessUserId, + @ApiParam(YyyfMoneyApi.ResetWallet.METHOD_COIN_NAME) @RequestParam(name = "coinName",required =true)String coinName, + @ApiParam(YyyfMoneyApi.ResetWallet.METHOD_BALANCE) @RequestParam(name = "balance",required =true) BigDecimal balance) { - boolean result=this.yyyfMoneyService.resetDigitWallet(assessUserId,coinName,balance); + boolean result=this.yyyfMoneyService.resetWallet(assessUserId,coinName,balance); return ResultDTO.requstSuccess(result); } - @PostMapping("/resetWallet") + /* @PostMapping("/resetWallet") @ApiOperation(value = YyyfMoneyApi.ResetWallet.METHOD_NAME, notes = YyyfMoneyApi.ResetWallet.METHOD_NOTE) public ResultDTO resetWallet(@ApiParam(YyyfMoneyApi.ResetWallet.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId",required =true) String assessUserId, @@ -72,5 +72,5 @@ public class YyyfMoneyController { boolean result=this.yyyfMoneyService.resetWallet(assessUserId,coinName,balance,payType,payMoney); return ResultDTO.requstSuccess(result); - } + }*/ } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/YyyfMoneyApi.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/YyyfMoneyApi.java index a046cd3..5dca39b 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/YyyfMoneyApi.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/YyyfMoneyApi.java @@ -22,21 +22,23 @@ public class YyyfMoneyApi { public static class ResetWallet { - public static final String METHOD_NAME = "法币交易"; + /* public static final String METHOD_NAME = "法币交易"; public static final String METHOD_NOTE = "balance为负数是是减少,正数是增加"; public static final String METHOD_ASSESS_USER_ID= "assessUser的主键ID"; public static final String METHOD_COIN_NAME="货币名称"; public static final String METHOD_BALANCE="个数"; public static final String METHOD_PAY_TYPE = "支付类型"; - public static final String METHOD_PAY_MONENY = "支付金额"; - } + public static final String METHOD_PAY_MONENY = "支付金额";*/ - public static class ResetDigitWallet { public static final String METHOD_NAME = "充币"; public static final String METHOD_NOTE = "balance、payMoney为负数是是减少,正数是增加"; public static final String METHOD_ASSESS_USER_ID= "assessUser的主键ID"; public static final String METHOD_COIN_NAME="货币名称"; public static final String METHOD_BALANCE="个数"; - } + +/* public static class ResetDigitWallet { + + + }*/ } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/YyyfMoneyService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/YyyfMoneyService.java index a970321..cf89a7b 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/YyyfMoneyService.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/YyyfMoneyService.java @@ -38,13 +38,13 @@ public interface YyyfMoneyService { /** - * @description 充币、提币 + * @description 充币、提币、法币交易 * @author zijie * @date 2020-07-12 22:45:43 * @param [assessUserId, coinName, balance] * @return boolean **/ - boolean resetDigitWallet(String assessUserId, String coinName, BigDecimal balance); + boolean resetWallet(String assessUserId, String coinName, BigDecimal balance); /** * @description 法币交易 @@ -53,5 +53,5 @@ public interface YyyfMoneyService { * @param [assessUserId, coinName, balance, payType, payMoney] * @return boolean **/ - boolean resetWallet(String assessUserId, String coinName, BigDecimal balance, String payType, BigDecimal payMoney); + // boolean resetWallet(String assessUserId, String coinName, BigDecimal balance, String payType, BigDecimal payMoney); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/YyyfMoneyServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/YyyfMoneyServiceImpl.java index 3de3e69..e024c55 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/YyyfMoneyServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/YyyfMoneyServiceImpl.java @@ -97,22 +97,27 @@ public class YyyfMoneyServiceImpl implements YyyfMoneyService { } @Override - public boolean resetDigitWallet(String assessUserId, String coinName, BigDecimal balance) { + public boolean resetWallet(String assessUserId, String coinName, BigDecimal balance) { YyyfMoney yyyfMoney = this.yyyfMoneyMapper.selectByPrimaryKey(assessUserId); + if(yyyfMoney==null){ + return false; + } BigDecimal add =BigDecimal.ZERO; + coinName=coinName.toLowerCase(); + switch (coinName) { - case"ZFB":{ + case"zfb":{ add = yyyfMoney.getAliPay().add(balance); yyyfMoney.setAliPay(add); break; } - case"WX":{ + case"wx":{ add= yyyfMoney.getWxPay().add(balance); yyyfMoney.setWxPay(add); break; } - case"BANK":{ + case"bank":{ add = yyyfMoney.getBankCard().add(balance); yyyfMoney.setBankCard(add); break; @@ -150,136 +155,4 @@ public class YyyfMoneyServiceImpl implements YyyfMoneyService { return true; } - @Override - public boolean resetWallet(String assessUserId, String coinName, BigDecimal balance, String payType, BigDecimal payMoney) { - YyyfMoney yyyfMoney = this.yyyfMoneyMapper.selectByPrimaryKey(assessUserId); - BigDecimal coninAdd =BigDecimal.ZERO; - switch (coinName) { - case "btc": { - coninAdd = yyyfMoney.getBtc().add(balance); - yyyfMoney.setBtc(coninAdd); - break; - } - case "usdt": { - coninAdd = yyyfMoney.getUsdt().add(balance); - yyyfMoney.setUsdt(coninAdd); - - break; - } - case "eth": { - coninAdd = yyyfMoney.getEth().add(balance); - yyyfMoney.setEth(coninAdd); - break; - } - case "eos": { - coninAdd = yyyfMoney.getEos().add(balance); - yyyfMoney.setEos(coninAdd); - break; - } - } - BigDecimal add=BigDecimal.ZERO; - switch (payType) { - case "ZFB": { - add = yyyfMoney.getAliPay().add(balance); - yyyfMoney.setAliPay(add); - break; - } - case "WX": { - add = yyyfMoney.getWxPay().add(balance); - yyyfMoney.setWxPay(add); - break; - } - case "BANK": { - add = yyyfMoney.getBankCard().add(balance); - yyyfMoney.setBankCard(add); - break; - } - default: - add=BigDecimal.ZERO.subtract(BigDecimal.ONE); - } - //只要有一个为负数则失败 - if(add.compareTo(BigDecimal.ZERO)==-1 || coninAdd.compareTo(BigDecimal.ZERO)==-1){ - return false; - }else{ - yyyfMoney.setUpdateTime(new Date()); - this.yyyfMoneyMapper.updateByPrimaryKeySelective(yyyfMoney); - } - return true; - } - - - /* - @Override - public boolean resetWallet(String assessUserId, String coinName, BigDecimal balance, Integer type) { - boolean result = false; - String name = currencyPair.substring(currencyPair.indexOf("-")).toLowerCase(); - CurrencyMarketDTO currencyMarketDTO =null; - if(name.equals("usdt")){ - currencyPair="BTC-USDT"; - currencyMarketDTO =this.currencyFeign.get(currencyPair); - currencyMarketDTO.setAmount(BigDecimal.ONE); - }else{ - currencyMarketDTO =this.currencyFeign.get(currencyPair); - } - if (currencyMarketDTO != null) { - YyyfMoney yyyfMoney = this.yyyfMoneyMapper.selectByPrimaryKey(assessUserId); - BigDecimal totalCnyMoney = currencyMarketDTO.getAmount().multiply(balance).multiply(BigDecimal.valueOf(currencyMarketDTO.getCnyAmount())); - BigDecimal aliPay = yyyfMoney.getAliPay(); - BigDecimal wxPay = yyyfMoney.getWxPay(); - BigDecimal bankCard = yyyfMoney.getBankCard(); - //总的账户余额 - BigDecimal totalAccount = aliPay.add(wxPay).add(bankCard); - //比较总资金 - if (totalCnyMoney.compareTo(totalAccount) != 1) { - //充币 - - switch (name) { - case "btc": { - BigDecimal add = yyyfMoney.getBtc().add(balance); - yyyfMoney.setBtc(add); - break; - } - case "usdt": { - BigDecimal add = yyyfMoney.getUsdt().add(balance); - yyyfMoney.setUsdt(add); - - break; - } - case "eth": { - BigDecimal add = yyyfMoney.getEth().add(balance); - yyyfMoney.setEth(add); - break; - } - case "eos": { - BigDecimal add = yyyfMoney.getEos().add(balance); - yyyfMoney.setEos(add); - break; - } - } - if(aliPay.compareTo(totalCnyMoney)!=-1){ - aliPay=aliPay.subtract(totalCnyMoney); - }else{ - if(aliPay.add(wxPay).compareTo(totalCnyMoney) !=-1){ - aliPay=BigDecimal.ZERO; - wxPay=wxPay.subtract(totalCnyMoney.subtract(aliPay)); - }else{ - aliPay=BigDecimal.ZERO; - wxPay=BigDecimal.ZERO; - bankCard=totalAccount.subtract(totalCnyMoney); - } - } - yyyfMoney.setAliPay(aliPay); - yyyfMoney.setWxPay(wxPay); - yyyfMoney.setBankCard(bankCard); - yyyfMoney.setUpdateTime(new Date()); - this.yyyfMoneyMapper.updateByPrimaryKeySelective(yyyfMoney); - result = true; - } - } - return result; - - - - }*/ - } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/bootstrap.yml b/blockchain-server/blockchain-server-yyyf/src/main/resources/bootstrap.yml index 9a734a7..b512d4c 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/resources/bootstrap.yml +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/bootstrap.yml @@ -29,4 +29,7 @@ yyyf: assessment: /api/db/v1.0/assessment #成绩同步(整场考试) assessmentList: /api/db/v1.0/assessmentList +rate: + riskFree: 0.04 +