src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
@@ -204,8 +204,7 @@ @PostMapping(value="/usdtToGusd") public Result usdtToGusd(@RequestBody @Valid UsdtToGusdDto usdtToGusdDto) { BigDecimal balance = usdtToGusdDto.getBalance(); Integer transfertype = usdtToGusdDto.getTransfertype(); return coinService.usdtToGusd(balance,transfertype); return coinService.usdtToGusd(balance); } /** @@ -217,6 +216,16 @@ BigDecimal balance = zhiYaGusdDto.getBalance(); return coinService.zhiYaGusd(balance); } /** * 赎回GUSD */ @ApiOperation(value="赎回GUSD", notes="赎回GUSD") @PostMapping(value="/shuhuiGusd") public Result shuhuiGusd(@RequestBody @Valid ShuhuiGusdDto shuhuiGusdDto) { BigDecimal balance = shuhuiGusdDto.getBalance(); return coinService.shuhuiGusd(balance); } } src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ShuhuiGusdDto.java
New file @@ -0,0 +1,17 @@ package com.xcong.excoin.modules.coin.parameter.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; import java.math.BigDecimal; @Data @ApiModel(value = "ShuhuiGusdDto", description = "参数接收类") public class ShuhuiGusdDto { @NotNull(message = "金额不能为空") @ApiModelProperty(value = "金额", example = "100") private BigDecimal balance; } src/main/java/com/xcong/excoin/modules/coin/parameter/dto/UsdtToGusdDto.java
@@ -19,7 +19,4 @@ @ApiModelProperty(value = "币种", example = "USDT") private String symbol; @NotNull(message = "账户类型不能为空") @ApiModelProperty(value = "转账类型1:转币币,2:转合约", example = "1") private Integer transfertype; } src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ZhiYaGusdDto.java
@@ -11,7 +11,7 @@ @ApiModel(value = "ZhiYaGusdDto", description = "参数接收类") public class ZhiYaGusdDto { @NotNull(message = "划转金额不能为空") @ApiModelProperty(value = "划转金额", example = "100") @NotNull(message = "金额不能为空") @ApiModelProperty(value = "金额", example = "100") private BigDecimal balance; } src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java
@@ -42,7 +42,9 @@ void updateWalletBalance(@Param("id") Long id, @Param("availableBalance")BigDecimal availableBalance,@Param("totalBalance")BigDecimal totalBalance, @Param("frozenBalance")BigDecimal frozenBalance); Result usdtToGusd(BigDecimal balance, Integer transfertype); Result usdtToGusd(BigDecimal balance); Result zhiYaGusd(BigDecimal balance); Result shuhuiGusd(BigDecimal balance); } src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
@@ -602,7 +602,7 @@ } @Override public Result usdtToGusd(BigDecimal balance, Integer transfertype) { public Result usdtToGusd(BigDecimal balance) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); if (balance.compareTo(BigDecimal.ZERO) <= 0) { @@ -711,6 +711,31 @@ return Result.ok(MessageSourceUtils.getString("member_service_0024")); } @Override public Result shuhuiGusd(BigDecimal balance) { //获取用户ID Long memberId = LoginUserUtils.getAppLoginUser().getId(); if (balance.compareTo(BigDecimal.ZERO) <= 0) { return Result.fail(MessageSourceUtils.getString("order_service_0010")); } //质押Gusd,质押数量进入冻结余额, String gusdName = CoinTypeEnum.GUSD.name(); MemberWalletCoinEntity gusdMemberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, gusdName); BigDecimal gusdAvailableBalance = gusdMemberWalletCoinEntity.getAvailableBalance(); BigDecimal gusdTotalBalance = gusdMemberWalletCoinEntity.getTotalBalance(); BigDecimal gusdfrozenBalance = gusdMemberWalletCoinEntity.getFrozenBalance(); BigDecimal frozen = gusdfrozenBalance.subtract(balance); if (frozen.compareTo(BigDecimal.ZERO) < 0) { return Result.fail(MessageSourceUtils.getString("zhiya_service_0001")); } BigDecimal total = gusdTotalBalance.subtract(balance); if (total.compareTo(BigDecimal.ZERO) < 0) { return Result.fail(MessageSourceUtils.getString("member_service_0005")); } return null; } public String generateSimpleSerialno(String userId) { StringBuilder sb = new StringBuilder(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); src/main/resources/i18n/messages_en_US.properties
@@ -241,3 +241,5 @@ submit_repeat=Do not repeat submission zhiya_service_0001=Redemption quantity is greater than pledge quantity src/main/resources/i18n/messages_zh_CN.properties
@@ -240,3 +240,5 @@ cancellation_fail=撤销失败 submit_repeat=请勿重复提交 zhiya_service_0001=赎回数量大于质押数量