Search in sources :

Example 1 with CurrencyAccount

use of com.whoiszxl.entity.CurrencyAccount in project shopzz by whoiszxl.

the class ShopzzFeignClientImpl method giveAddress.

@Override
@Transactional
public ResponseResult<RechargeResponse> giveAddress(String orderId, String amount) {
    // 1. 获取货币信息
    Currency ethInfo = currencyService.getCurrencyByName(currencyName);
    AssertUtils.isNotNull(ethInfo, "数据库未配置货币信息:" + currencyName);
    // 2. 通过keystore的方式生成一个以太坊地址
    EthereumAddress ethereumAddress = ethereumService.createAddressByFile();
    String qrCodeData = getQrCodeData(amount, ethereumAddress.getAddress());
    // 3. 保存keystore文件与地址的对应关系
    CurrencyAccount account = new CurrencyAccount();
    account.setAddress(ethereumAddress.getAddress());
    account.setCurrencyId(ethInfo.getId());
    account.setCurrencyName(ethInfo.getCurrencyName());
    account.setKeystoreName(ethereumAddress.getKeystoreName());
    account.setMnemonic(ethereumAddress.getMnemonic());
    currencyAccountService.save(account);
    return ResponseResult.buildSuccess(new RechargeResponse(ethInfo.getId(), ethereumAddress.getAddress(), qrCodeData));
}
Also used : EthereumAddress(com.whoiszxl.common.EthereumAddress) CurrencyAccount(com.whoiszxl.entity.CurrencyAccount) RechargeResponse(com.whoiszxl.entity.response.RechargeResponse) Currency(com.whoiszxl.entity.Currency) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with CurrencyAccount

use of com.whoiszxl.entity.CurrencyAccount in project shopzz by whoiszxl.

the class EthFeignClientImpl method giveAddress.

@Override
@Transactional
@PostMapping("/createRecharge/{orderId}/{amount}")
public ResponseResult<RechargeResponse> giveAddress(String orderId, String amount) {
    // 1. 获取货币信息
    Currency ethInfo = currencyService.getCurrencyByName(currencyName);
    AssertUtils.isNotNull(ethInfo, "数据库未配置货币信息:" + currencyName);
    // 2. 通过keystore的方式生成一个以太坊地址
    EthereumAddress ethereumAddress = ethereumService.createAddressByFile();
    String qrCodeData = getQrCodeData(amount, ethereumAddress.getAddress());
    // 3. 保存keystore文件与地址的对应关系
    CurrencyAccount account = new CurrencyAccount();
    account.setAddress(ethereumAddress.getAddress());
    account.setCurrencyId(ethInfo.getId());
    account.setCurrencyName(ethInfo.getCurrencyName());
    account.setKeystoreName(ethereumAddress.getKeystoreName());
    account.setMnemonic(ethereumAddress.getMnemonic());
    currencyAccountService.save(account);
    return ResponseResult.buildSuccess(new RechargeResponse(ethInfo.getId(), ethereumAddress.getAddress(), qrCodeData));
}
Also used : EthereumAddress(com.whoiszxl.common.EthereumAddress) CurrencyAccount(com.whoiszxl.entity.CurrencyAccount) RechargeResponse(com.whoiszxl.entity.response.RechargeResponse) Currency(com.whoiszxl.entity.Currency) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with CurrencyAccount

use of com.whoiszxl.entity.CurrencyAccount in project shopzz by whoiszxl.

the class ZXLFeignClientImpl method giveAddress.

@Override
@Transactional
public ResponseResult<RechargeResponse> giveAddress(String orderId, String amount) {
    // 1. 获取货币信息
    Currency ethInfo = currencyService.getCurrencyByName(currencyName);
    AssertUtils.isNotNull(ethInfo, "数据库未配置货币信息:" + currencyName);
    // 2. 通过keystore的方式生成一个以太坊地址
    EthereumAddress ethereumAddress = ethereumService.createAddressByFile();
    String qrCodeData = getQrCodeData(amount, ethereumAddress.getAddress());
    // 3. 保存keystore文件与地址的对应关系
    CurrencyAccount account = new CurrencyAccount();
    account.setAddress(ethereumAddress.getAddress());
    account.setCurrencyId(ethInfo.getId());
    account.setCurrencyName(ethInfo.getCurrencyName());
    account.setKeystoreName(ethereumAddress.getKeystoreName());
    account.setMnemonic(ethereumAddress.getMnemonic());
    currencyAccountService.save(account);
    return ResponseResult.buildSuccess(new RechargeResponse(ethInfo.getId(), ethereumAddress.getAddress(), qrCodeData));
}
Also used : EthereumAddress(com.whoiszxl.common.EthereumAddress) CurrencyAccount(com.whoiszxl.entity.CurrencyAccount) RechargeResponse(com.whoiszxl.entity.response.RechargeResponse) Currency(com.whoiszxl.entity.Currency) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

EthereumAddress (com.whoiszxl.common.EthereumAddress)3 Currency (com.whoiszxl.entity.Currency)3 CurrencyAccount (com.whoiszxl.entity.CurrencyAccount)3 RechargeResponse (com.whoiszxl.entity.response.RechargeResponse)3 Transactional (org.springframework.transaction.annotation.Transactional)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)1