From 0c5bb71fdce5f677b6cc7320795713d599e6f04f Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Wed, 23 Feb 2022 14:19:56 +0800 Subject: [PATCH] 20222223 --- src/main/resources/i18n/messages_zh_CN.properties | 2 + src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java | 13 +++++- src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ZhiYaGusdDto.java | 4 +- src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java | 27 +++++++++++++ src/main/java/com/xcong/excoin/modules/coin/parameter/dto/UsdtToGusdDto.java | 3 - src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java | 4 + src/main/resources/i18n/messages_en_US.properties | 2 + src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ShuhuiGusdDto.java | 17 ++++++++ 8 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java b/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java index 12e1d8a..0cfeb74 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java +++ b/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); + } } diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ShuhuiGusdDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ShuhuiGusdDto.java new file mode 100644 index 0000000..5231c35 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ShuhuiGusdDto.java @@ -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; +} diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/UsdtToGusdDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/UsdtToGusdDto.java index ccc1b70..3640770 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/UsdtToGusdDto.java +++ b/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; } diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ZhiYaGusdDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ZhiYaGusdDto.java index 6fd22bb..218a15d 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/ZhiYaGusdDto.java +++ b/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; } diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java b/src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java index a2946bb..bf00adf 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java +++ b/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); } diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java index 7692d4a..a2b4b05 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java +++ b/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"); diff --git a/src/main/resources/i18n/messages_en_US.properties b/src/main/resources/i18n/messages_en_US.properties index fc356e7..bcb900b 100644 --- a/src/main/resources/i18n/messages_en_US.properties +++ b/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 + diff --git a/src/main/resources/i18n/messages_zh_CN.properties b/src/main/resources/i18n/messages_zh_CN.properties index 0fdc300..fb28c93 100644 --- a/src/main/resources/i18n/messages_zh_CN.properties +++ b/src/main/resources/i18n/messages_zh_CN.properties @@ -240,3 +240,5 @@ cancellation_fail=撤销失败 submit_repeat=请勿重复提交 + +zhiya_service_0001=赎回数量大于质押数量 -- Gitblit v1.9.1