Search in sources :

Example 1 with RechargeResponse

use of com.whoiszxl.entity.response.RechargeResponse in project shopzz by whoiszxl.

the class DcPayInfoBuilder method buildAddress.

/**
 * 构建地址信息
 * @return
 */
public DcPayInfoBuilder buildAddress(Order order) {
    CreateAddressFeignClient createAddressFeignClient = createDcAddressFactory.get(dcName);
    ResponseResult<RechargeResponse> rechargeResponseResult = createAddressFeignClient.giveAddress(order.getId().toString(), order.getTotalAmount().toPlainString());
    if (!rechargeResponseResult.isOk()) {
        ExceptionCatcher.catchValidateEx(ResponseResult.buildError("支付创建失败"));
    }
    RechargeResponse rechargeResponse = rechargeResponseResult.getData();
    this.dcPayInfo.setCurrencyName(dcName);
    this.dcPayInfo.setCurrencyId(rechargeResponse.getCurrencyId());
    this.dcPayInfo.setToAddress(rechargeResponse.getAddress());
    this.dcPayInfo.setQrcodeData(rechargeResponse.getQrCodeData());
    return this;
}
Also used : CreateAddressFeignClient(com.whoiszxl.feign.CreateAddressFeignClient) RechargeResponse(com.whoiszxl.entity.response.RechargeResponse)

Example 2 with RechargeResponse

use of com.whoiszxl.entity.response.RechargeResponse 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 3 with RechargeResponse

use of com.whoiszxl.entity.response.RechargeResponse 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 4 with RechargeResponse

use of com.whoiszxl.entity.response.RechargeResponse in project shopzz by whoiszxl.

the class BtcFeignClientImpl method giveAddress.

@Override
@Transactional
@PostMapping("/createRecharge/{orderId}/{amount}")
public ResponseResult<RechargeResponse> giveAddress(String orderId, String amount) {
    // 1. 获取货币信息
    Currency btcInfo = currencyService.getCurrencyByName(currencyName);
    AssertUtils.isNotNull(btcInfo, "数据库未配置货币信息:" + currencyName);
    // 2. 生成bitcoin地址
    String newAddress = bitcoinClient.getNewAddress(orderId);
    return ResponseResult.buildSuccess(new RechargeResponse(btcInfo.getId(), newAddress, amount));
}
Also used : 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 5 with RechargeResponse

use of com.whoiszxl.entity.response.RechargeResponse 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

RechargeResponse (com.whoiszxl.entity.response.RechargeResponse)6 Currency (com.whoiszxl.entity.Currency)4 Transactional (org.springframework.transaction.annotation.Transactional)4 EthereumAddress (com.whoiszxl.common.EthereumAddress)3 CurrencyAccount (com.whoiszxl.entity.CurrencyAccount)3 CreateAddressFeignClient (com.whoiszxl.feign.CreateAddressFeignClient)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2