实现转指定trx数量功能

pull/520/head
dorion 2024-05-20 01:57:38 +08:00
parent ac9c0a7f03
commit dabd9aefb6
5 changed files with 44 additions and 16 deletions

View File

@ -26,7 +26,7 @@
<label class="col-sm-3 control-label">套餐类型:</label>
<div class="col-sm-8">
<select name="energyBusiType" class="form-control m-b" th:with="type=${@dict.getType('sys_energy_busi_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
<option th:each="dict : ${type}" th:unless="${dict.dictValue == '1' || dict.dictValue == '2'}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>

View File

@ -10,7 +10,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">付款地址:</label>
<div class="col-sm-8">
<input name="fromAddress" class="form-control" type="text">
<input name="fromAddress" class="form-control" type="text" required>
</div>
</div>
@ -22,6 +22,13 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">转出金额TRX</label>
<div class="col-sm-8">
<input name="trxAmount" class="form-control" type="text">
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />

View File

@ -107,11 +107,23 @@
},
{
field: 'usdtAmount',
title: '转入金额'
title: '转入金额',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return value + ' USDT' ;
}
},
{
field: 'trxAmount',
title: '转出金额'
title: '转出金额',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return value + ' TRX' ;
}
},
{
field: 'exchangeRate',
@ -119,7 +131,8 @@
},
{
field: 'trxTxId',
title: 'TRX订单'
title: 'TRX订单',
visible: false
},
{
field: 'orginalExchangeRate',
@ -136,7 +149,8 @@
},
{
field: 'lcd',
title: '更新时间'
title: '更新时间',
visible: false
},
{
field: 'lcu',

View File

@ -193,8 +193,8 @@ public class Usdt2TrxTransferHandler {
.setUsdtTxId(transactionId)
.setUsdtAmount(transferValue)
.setTrxAmount(trxValue)
.setExchangeRate(oneUsdtToTrxPair.getFirst())
.setOrginalExchangeRate(oneUsdtToTrxPair.getSecond())
.setExchangeRate(oneUsdtToTrxPair == null ? null : oneUsdtToTrxPair.getFirst())
.setOrginalExchangeRate(oneUsdtToTrxPair == null ? null :oneUsdtToTrxPair.getSecond())
.setTrxTxId(txId)
.setFcu("system")
.setLcu("system");

View File

@ -70,20 +70,27 @@ public class UsdtExchangeInfoServiceImpl implements IUsdtExchangeInfoService {
*/
@Override
public int insertUsdtExchangeInfo(UsdtExchangeInfo usdtExchangeInfo) throws Exception {
BigDecimal oneUsdtToTrx;
String systronApiSwitch = configService.selectConfigByKey("sys.tron.api");
BigDecimal usdtAmount = usdtExchangeInfo.getUsdtAmount();
BigDecimal trxAmount = usdtExchangeInfo.getTrxAmount();
Preconditions.checkState(usdtAmount != null ^ trxAmount != null, "转入USDT和转出TR数量不能同时录入,也不能同时为空");
Pair<BigDecimal, BigDecimal> oneUsdtToTrxPair = null;
if (UserConstants.YES.equals(systronApiSwitch)) {
BigDecimal trxValue = null;
if (usdtAmount != null) {
String systronApiSwitch = configService.selectConfigByKey("sys.tron.api");
if (UserConstants.YES.equals(systronApiSwitch)) {
// oneUsdtToTrx = usdt2TrxTransferHandler.getOneUsdtToTrx().getFirst();
oneUsdtToTrxPair = usdt2TrxTransferHandler.getOneUsdtToTrx();
oneUsdtToTrxPair = usdt2TrxTransferHandler.getOneUsdtToTrx();
} else {
oneUsdtToTrxPair = Pair.of(BigDecimal.TEN, BigDecimal.TEN);
}
trxValue = usdtAmount.multiply(oneUsdtToTrxPair.getFirst());
} else {
oneUsdtToTrxPair=Pair.of(BigDecimal.TEN,BigDecimal.TEN);
trxValue = trxAmount;
}
BigDecimal usdtAmount = usdtExchangeInfo.getUsdtAmount();
BigDecimal trxValue = usdtAmount.multiply(oneUsdtToTrxPair.getFirst());
String accountAddress = usdtExchangeInfo.getAccountAddress();
if (StringUtils.isEmpty(accountAddress)) {
AccountAddressInfo accountAddressInfoExample = new AccountAddressInfo();