|
|
|
@ -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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|