From 4f9e3043fa36daa7ce18b358e38bd5d5c42bc0c1 Mon Sep 17 00:00:00 2001
From: gao <gaoleox@163>
Date: Tue, 26 May 2020 11:32:06 +0800
Subject: [PATCH] Merge branch 'master' of https://chonggaoxiao:xcg523511090712@gitee.com/chonggaoxiao/new_excoin.git
---
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java | 25 ++
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java | 44 ---
src/main/java/com/xcong/excoin/configurations/properties/CustomRabbitProperties.java | 19 +
src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java | 11
src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java | 134 +++++++-----
src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java | 63 +++++
src/test/java/com/xcong/excoin/RabbitMqTest.java | 24 ++
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeInfoVo.java | 39 +++
src/main/java/com/xcong/excoin/modules/coin/service/CoinService.java | 2
src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java | 2
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeVo.java | 17 +
pom.xml | 11
src/main/java/com/xcong/excoin/common/LoginUserUtils.java | 18 +
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletContractInfoVo.java | 43 +++
src/main/java/com/xcong/excoin/rabbit/producer/TestProducer.java | 42 +++
src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java | 25 +
src/main/java/com/xcong/excoin/rabbit/consumer/TestConsumer.java | 21 +
src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java | 5
src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java | 2
src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java | 7
src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java | 21 -
src/main/resources/application.yml | 15 +
src/test/java/com/xcong/excoin/RSATest.java | 7
src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceFromAgentDto.java | 26 ++
24 files changed, 484 insertions(+), 139 deletions(-)
diff --git a/pom.xml b/pom.xml
index 20f2f96..eaea49e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,6 +27,8 @@
<mapstruct.version>1.3.1.Final</mapstruct.version>
<hutool.version>5.3.1</hutool.version>
<fastjson.version>1.2.61</fastjson.version>
+ <netty.version>4.1.33.Final</netty.version>
+ <dom4j.version>1.6.1</dom4j.version>
</properties>
<dependencies>
@@ -43,6 +45,11 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- <dependency>-->
@@ -166,14 +173,14 @@
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
- <version>1.6.1</version>
+ <version>${dom4j.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
- <version>4.1.33.Final</version>
+ <version>${netty.version}</version>
</dependency>
</dependencies>
diff --git a/src/main/java/com/xcong/excoin/common/LoginUserUtils.java b/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
index dbdd9d2..64c0aa2 100644
--- a/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
+++ b/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.common;
+import com.xcong.excoin.common.exception.GlobalException;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
@@ -17,6 +18,23 @@
public static MemberEntity getAppLoginUser() {
if (SecurityContextHolder.getContext().getAuthentication().getPrincipal().equals(ANON)) {
+ throw new GlobalException("无法获取登陆信息");
+ } else {
+ return (MemberEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+ }
+ }
+
+ public static String getAppLoginUserToken() {
+ return (String) SecurityContextHolder.getContext().getAuthentication().getCredentials();
+ }
+
+ /**
+ * mybatis 拦截器专用
+ *
+ * @return MemberEntity
+ */
+ public static MemberEntity getUser() {
+ if (SecurityContextHolder.getContext().getAuthentication().getPrincipal().equals(ANON)) {
return null;
} else {
return (MemberEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
diff --git a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java
new file mode 100644
index 0000000..eec7531
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java
@@ -0,0 +1,63 @@
+package com.xcong.excoin.configurations;
+
+import com.xcong.excoin.configurations.properties.CustomRabbitProperties;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.DirectExchange;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
+
+import javax.annotation.Resource;
+
+/**
+ * @author wzy
+ * @date 2020-05-25
+ **/
+@Configuration
+public class RabbitMqConfig {
+
+ public static final String EXCHANGE_ONE = "excoin-exchange-one";
+
+ public static final String QUEUE_TEST = "test-queue";
+
+ public static final String ROUTING_KEY_TEST = "test-routingKey";
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+// @Bean
+// public ConnectionFactory connectionFactory() {
+// CachingConnectionFactory connectionFactory = new CachingConnectionFactory(customRabbitProperties.getHost(), customRabbitProperties.getPort());
+// connectionFactory.setUsername(customRabbitProperties.getUsername());
+// connectionFactory.setPassword(customRabbitProperties.getPassword());
+// connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
+// return connectionFactory;
+// }
+
+ @Bean
+ @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+ public RabbitTemplate rabbitTemplate() {
+ return new RabbitTemplate(connectionFactory);
+ }
+
+ @Bean
+ public DirectExchange defaultExchange() {
+ return new DirectExchange(EXCHANGE_ONE);
+ }
+
+ @Bean
+ public Queue testQueue() {
+ return new Queue(QUEUE_TEST, true);
+ }
+
+ @Bean
+ public Binding binding() {
+ return BindingBuilder.bind(testQueue()).to(defaultExchange()).with(ROUTING_KEY_TEST);
+ }
+
+}
diff --git a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java b/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
index f7b0c87..5e69b7a 100644
--- a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
+++ b/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
@@ -27,10 +27,7 @@
@Override
public Object intercept(Invocation invocation) throws Throwable {
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
- String sqlId = mappedStatement.getId();
- log.info("----sqlId----" + sqlId);
SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
- log.info("-------------->{}", sqlCommandType);
Object parameter = invocation.getArgs()[1];
if (parameter == null) {
@@ -75,7 +72,7 @@
}
public void injectForInsert(Object o) {
- MemberEntity member = LoginUserUtils.getAppLoginUser();
+ MemberEntity member = LoginUserUtils.getUser();
if (o instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) o;
if (member != null) {
@@ -92,7 +89,7 @@
}
public void injectForUpdate(Object o) {
- MemberEntity member = LoginUserUtils.getAppLoginUser();
+ MemberEntity member = LoginUserUtils.getUser();
if (o instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) o;
if (member != null) {
diff --git a/src/main/java/com/xcong/excoin/configurations/properties/CustomRabbitProperties.java b/src/main/java/com/xcong/excoin/configurations/properties/CustomRabbitProperties.java
new file mode 100644
index 0000000..47ddc4c
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/configurations/properties/CustomRabbitProperties.java
@@ -0,0 +1,19 @@
+package com.xcong.excoin.configurations.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author wzy
+ * @date 2020-05-25
+ **/
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "custom.rabbitmq")
+public class CustomRabbitProperties {
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+}
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 b198904..51f7399 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
@@ -5,18 +5,22 @@
import javax.annotation.Resource;
import javax.validation.Valid;
+import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeVo;
+import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
+import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletContractInfoVo;
+
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceDto;
+import com.xcong.excoin.modules.coin.parameter.dto.TransferOfBalanceFromAgentDto;
import com.xcong.excoin.modules.coin.service.CoinService;
import io.swagger.annotations.Api;
@@ -61,6 +65,7 @@
* @return
*/
@ApiOperation(value="获取我的合约账户信息", notes="获取我的合约账户信息")
+ @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberWalletContractInfoVo.class)})
@GetMapping(value="/getWalletContractById")
public Result getWalletContractById() {
return coinService.getWalletContractById();
@@ -90,7 +95,8 @@
* 查询代理账户里面的资产余额
* @return
*/
- @ApiOperation(value="查询代理账户里面的可用资产余额", notes="查询代理账户里面的可用资产余额")
+ @ApiOperation(value="查询代理账户信息", notes="查询代理账户信息")
+ @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberWalletAgentInfoVo.class)})
@GetMapping(value="/findWalletAgentBySymbol")
public Result findWalletAgentBySymbol() {
return coinService.findWalletAgentBySymbol();
@@ -101,6 +107,7 @@
* @return
*/
@ApiOperation(value="获取币币资产交易记录", notes="获取币币资产交易记录")
+ @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAccountMoneyChangeVo.class)})
@GetMapping(value="/getWalletCoinRecords")
public Result getWalletCoinRecords() {
return coinService.getWalletCoinRecords();
@@ -111,9 +118,10 @@
* @return
*/
@ApiOperation(value="获取合约资产交易记录", notes="获取合约资产交易记录")
+ @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAccountMoneyChangeVo.class)})
@GetMapping(value="/getWalletContractRecords")
- public Result getWalletContractRecords(@ApiParam(name="symbol",value="币种",required=true)String symbol) {
- return coinService.getWalletContractRecords(symbol);
+ public Result getWalletContractRecords() {
+ return coinService.getWalletContractRecords();
}
/**
@@ -121,6 +129,7 @@
* @return
*/
@ApiOperation(value="获取代理资产交易记录", notes="获取代理资产交易记录")
+ @ApiResponses({@ApiResponse( code = 200, message = "success", response = MemberAccountMoneyChangeVo.class)})
@GetMapping(value="/getWalletAgentRecords")
public Result getWalletAgentRecords() {
return coinService.getWalletAgentRecords();
@@ -154,11 +163,11 @@
* 代理账户划转到USDT账户
* @return
*/
- @ApiOperation(value="代理账户划转到合约或币币USDT账户()", notes="代理账户划转到合约或币币USDT账户")
+ @ApiOperation(value="代理账户划转到合约或币币USDT账户", notes="代理账户划转到合约或币币USDT账户")
@PostMapping(value="/agentTransferToWalletCoin")
- public Result agentTransferToWalletCoin(@RequestBody @Valid TransferOfBalanceDto transferOfBalanceDto) {
- BigDecimal balance = transferOfBalanceDto.getBalance();
- Integer transfertype = transferOfBalanceDto.getTransfertype();
+ public Result agentTransferToWalletCoin(@RequestBody @Valid TransferOfBalanceFromAgentDto transferOfBalanceFromAgentDto) {
+ BigDecimal balance = transferOfBalanceFromAgentDto.getBalance();
+ Integer transfertype = transferOfBalanceFromAgentDto.getTransfertype();
return coinService.agentTransferToWalletCoin(balance,transfertype);
}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java
index b69daf2..2a54cf0 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/InOrderCoinDto.java
@@ -9,7 +9,7 @@
import lombok.Data;
@Data
-@ApiModel(value = "进入交易页面参数接收类", description = "进入交易页面参数接收类")
+@ApiModel(value = "InOrderCoinDto", description = "进入交易页面参数接收类")
public class InOrderCoinDto {
@NotNull(message = "划转金额不能为空")
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
index bdff678..2042a66 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/SubmitSalesWalletCoinOrderDto.java
@@ -7,7 +7,7 @@
import lombok.Data;
@Data
-@ApiModel(value = "提交买卖订单接收类", description = "提交买卖订单接收类")
+@ApiModel(value = "SubmitSalesWalletCoinOrderDto", description = "提交买卖订单接收类")
public class SubmitSalesWalletCoinOrderDto {
@ApiModelProperty(value = "币种", example = "BTC")
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java
index 3bf19e0..e1f9967 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceDto.java
@@ -9,7 +9,7 @@
import lombok.Data;
@Data
-@ApiModel(value = "资金划转参数接收类", description = "资金划转参数接收类")
+@ApiModel(value = "TransferOfBalanceDto", description = "资金划转参数接收类")
public class TransferOfBalanceDto {
@NotNull(message = "划转金额不能为空")
@@ -20,7 +20,4 @@
@ApiModelProperty(value = "币种", example = "USDT")
private String symbol;
- @NotNull(message = "账户类型不能为空")
- @ApiModelProperty(value = "账户类型", example = "1")
- private Integer transfertype;
}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceFromAgentDto.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceFromAgentDto.java
new file mode 100644
index 0000000..bd7f8d4
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/dto/TransferOfBalanceFromAgentDto.java
@@ -0,0 +1,26 @@
+package com.xcong.excoin.modules.coin.parameter.dto;
+
+import java.math.BigDecimal;
+
+import javax.validation.constraints.NotNull;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+@Data
+@ApiModel(value = "TransferOfBalanceFromAgentDto", description = "资金划转参数接收类")
+public class TransferOfBalanceFromAgentDto {
+
+ @NotNull(message = "划转金额不能为空")
+ @ApiModelProperty(value = "划转金额", example = "100")
+ private BigDecimal balance;
+
+ @NotNull(message = "币种不能为空")
+ @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/vo/MemberAccountMoneyChangeInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeInfoVo.java
new file mode 100644
index 0000000..67e7b67
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeInfoVo.java
@@ -0,0 +1,39 @@
+package com.xcong.excoin.modules.coin.parameter.vo;
+
+import java.math.BigDecimal;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "资产交易记录详情信息返回", description = "资产交易记录详情信息返回")
+public class MemberAccountMoneyChangeInfoVo {
+
+ /**
+ * 币种
+ */
+ @ApiModelProperty(value = "币种")
+ private String symbol;
+ /**
+ * 金额
+ */
+ @ApiModelProperty(value = "金额")
+ private BigDecimal amount;
+ /**
+ * 记录内容
+ */
+ @ApiModelProperty(value = "记录内容")
+ private String content;
+ /**
+ * 类型【1:币币资产2:合约资产3:代理资产】
+ */
+ @ApiModelProperty(value = "类型【1:币币资产2:合约资产3:代理资产】")
+ private int type;
+ /**
+ * 状态【0:待审核 1:成功2:失败】
+ */
+ @ApiModelProperty(value = "状态【0:待审核 1:成功2:失败】")
+ private int status;
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeVo.java
new file mode 100644
index 0000000..cd7e4ef
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberAccountMoneyChangeVo.java
@@ -0,0 +1,17 @@
+package com.xcong.excoin.modules.coin.parameter.vo;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "资产交易记录信息返回", description = "资产交易记录信息返回")
+public class MemberAccountMoneyChangeVo {
+
+ @ApiModelProperty(value = "资产交易记录详情信息")
+ private List<MemberAccountMoneyChangeInfoVo> memberAccountMoneyChangeInfoVo;
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java
new file mode 100644
index 0000000..3101ab6
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletAgentInfoVo.java
@@ -0,0 +1,25 @@
+package com.xcong.excoin.modules.coin.parameter.vo;
+
+import java.math.BigDecimal;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "代理账户信息返回", description = "代理账户信息返回")
+public class MemberWalletAgentInfoVo {
+
+ /**
+ * 总金额
+ */
+ @ApiModelProperty(value = "总金额")
+ private BigDecimal totalBalance;
+
+ /**
+ * 总人民币金额
+ */
+ @ApiModelProperty(value = "总人民币金额")
+ private BigDecimal totalRMBBalance;
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java
index 3c1884b..2098c61 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinInfoVo.java
@@ -3,7 +3,9 @@
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+@Data
public class MemberWalletCoinInfoVo {
/**
@@ -36,46 +38,4 @@
@ApiModelProperty(value = "冻结金额")
private BigDecimal frozenBalance;
- public String getWalletCode() {
- return walletCode;
- }
-
- public void setWalletCode(String walletCode) {
- this.walletCode = walletCode;
- }
-
- public Long getMemberId() {
- return memberId;
- }
-
- public void setMemberId(Long memberId) {
- this.memberId = memberId;
- }
-
- public BigDecimal getAvailableBalance() {
- return availableBalance;
- }
-
- public void setAvailableBalance(BigDecimal availableBalance) {
- this.availableBalance = availableBalance;
- }
-
- public BigDecimal getTotalBalance() {
- return totalBalance;
- }
-
- public void setTotalBalance(BigDecimal totalBalance) {
- this.totalBalance = totalBalance;
- }
-
- public BigDecimal getFrozenBalance() {
- return frozenBalance;
- }
-
- public void setFrozenBalance(BigDecimal frozenBalance) {
- this.frozenBalance = frozenBalance;
- }
-
-
-
}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java
index 54f5d65..abdd2de 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletCoinVo.java
@@ -5,10 +5,12 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
/**
* @author xy
*/
+@Data
@ApiModel(value = "币币账户信息返回", description = "币币账户信息返回")
public class MemberWalletCoinVo {
@@ -22,24 +24,5 @@
@ApiModelProperty(value = "币种详情")
private List<MemberWalletCoinInfoVo> memberWalletCoinInfoVo;
-
- public BigDecimal getTotalUsdt() {
- return totalUsdt;
- }
- public void setTotalUsdt(BigDecimal totalUsdt) {
- this.totalUsdt = totalUsdt;
- }
- public BigDecimal getTotalCny() {
- return totalCny;
- }
- public void setTotalCny(BigDecimal totalCny) {
- this.totalCny = totalCny;
- }
- public List<MemberWalletCoinInfoVo> getMemberWalletCoinInfoVo() {
- return memberWalletCoinInfoVo;
- }
- public void setMemberWalletCoinInfoVo(List<MemberWalletCoinInfoVo> memberWalletCoinInfoVo) {
- this.memberWalletCoinInfoVo = memberWalletCoinInfoVo;
- }
}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletContractInfoVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletContractInfoVo.java
new file mode 100644
index 0000000..a184442
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/MemberWalletContractInfoVo.java
@@ -0,0 +1,43 @@
+package com.xcong.excoin.modules.coin.parameter.vo;
+
+import java.math.BigDecimal;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "合约账户信息返回", description = "合约账户信息返回")
+public class MemberWalletContractInfoVo {
+
+ /**
+ * 用户Id
+ */
+ @ApiModelProperty(value = "用户Id")
+ private Long memberId;
+
+ /**
+ * 可用余额
+ */
+ @ApiModelProperty(value = "可用余额")
+ private BigDecimal availableBalance;
+
+ /**
+ * 总金额
+ */
+ @ApiModelProperty(value = "总金额")
+ private BigDecimal totalBalance;
+
+ /**
+ * 总人民币金额
+ */
+ @ApiModelProperty(value = "总人民币金额")
+ private BigDecimal totalRMBBalance;
+
+ /**
+ * 冻结金额
+ */
+ @ApiModelProperty(value = "冻结金额")
+ private BigDecimal frozenBalance;
+
+}
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 82945c8..9c612d8 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
@@ -22,7 +22,7 @@
public Result getWalletCoinRecords();
- public Result getWalletContractRecords(String symbol);
+ public Result getWalletContractRecords();
public Result getWalletAgentRecords();
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 7f8ea9e..a5615d3 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
@@ -2,9 +2,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -18,8 +16,11 @@
import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao;
import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange;
import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
+import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
+import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinInfoVo;
import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
+import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletContractInfoVo;
import com.xcong.excoin.modules.coin.service.CoinService;
import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
@@ -51,49 +52,51 @@
@Override
public Result getWalletCoin() {
- try {
- BigDecimal totalUsdt = BigDecimal.ZERO;
//获取用户ID
Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne();
BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
+ BigDecimal totalUsdts = BigDecimal.ZERO;
if(!StrUtil.isEmpty(memberId.toString())) {
List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
-
List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>();
- MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
- if(ObjectUtil.isNotEmpty(memberWalletCoinlist)) {
+
+ if(CollUtil.isNotEmpty(memberWalletCoinlist)) {
for(MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
- memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance());
- memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance());
+ MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
+ memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
- memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance());
+ memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode());
memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
}
}
-
- if(CollUtil.isNotEmpty(memberWalletCoinlist)) {
- for(MemberWalletCoinEntity walletCoin : memberWalletCoinlist) {
+ if(CollUtil.isNotEmpty(memberWalletCoinInfoVolist)) {
+ for(MemberWalletCoinInfoVo walletCoin : memberWalletCoinInfoVolist) {
if(MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
+ BigDecimal totalUsdt = BigDecimal.ZERO;
totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
+ totalUsdts = totalUsdts.add(totalUsdt);
BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
walletCoin.setTotalBalance(totalCny.setScale(4, BigDecimal.ROUND_DOWN));
}else {
BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
BigDecimal closePrice = new BigDecimal("10.0000");
+ BigDecimal totalUsdt = BigDecimal.ZERO;
//Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(walletCoin.getWalletCode()+"/USDT");
totalUsdt = totalUsdt.add(amount.multiply(closePrice));
- walletCoin.setTotalBalance(totalUsdt.multiply(closePrice).multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+ totalUsdts = totalUsdts.add(totalUsdt);
+ walletCoin.setTotalBalance(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
}
}
}
MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
- memberWalletCoinVo.setTotalUsdt(totalUsdt.setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinVo.setTotalCny(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinInfoVolist);
return Result.ok(memberWalletCoinVo);
}else {
@@ -120,20 +123,15 @@
memberWalletCoinlist.add(coin);
MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
- memberWalletCoinVo.setTotalUsdt(totalUsdt.setScale(4, BigDecimal.ROUND_DOWN));
- memberWalletCoinVo.setTotalCny(totalUsdt.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinlist);;
return Result.ok(memberWalletCoinVo);
}
- } catch (Exception e) {
- e.printStackTrace();
- return Result.fail(MessageSourceUtils.getString("member_service_0003"));
- }
}
@Override
public Result getWalletCoinBySymbol(String symbol) {
- try {
//获取用户ID
Long memberId = LoginUserUtils.getAppLoginUser().getId();
MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId,symbol);
@@ -157,10 +155,6 @@
}
}
return Result.ok(memberWalletCoinInfoVo);
- } catch (Exception e) {
- e.printStackTrace();
- return Result.fail(MessageSourceUtils.getString("member_service_0003"));
- }
}
@Override
@@ -185,9 +179,6 @@
BigDecimal profitAndLoss = new BigDecimal("50.000");
//获取总付款
BigDecimal totalPayment = new BigDecimal("50.000");
-
- walletContract.setFrozenBalance(totalPayment.setScale(4, BigDecimal.ROUND_DOWN));
-
BigDecimal lastTotalBalance = new BigDecimal("0");
BigDecimal totalBalance = walletContract.getTotalBalance();
lastTotalBalance = totalBalance.add(profitAndLoss);
@@ -195,14 +186,13 @@
lastTotalBalance = new BigDecimal("0");
}
- walletContract.setAvailableBalance(walletContract.getAvailableBalance());
- walletContract.setTotalBalance(lastTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
+ MemberWalletContractInfoVo memberWalletContractInfoVo = new MemberWalletContractInfoVo();
+ memberWalletContractInfoVo.setFrozenBalance(totalPayment.setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletContractInfoVo.setAvailableBalance(walletContract.getAvailableBalance());
+ memberWalletContractInfoVo.setTotalBalance(lastTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletContractInfoVo.setTotalRMBBalance(lastTotalBalance.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
- Map<String,Object> map = new HashMap<String, Object>();
- map.put(MemberWalletCoinEnum.WALLETCOINUSDT.getValue(), lastTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
- map.put(MemberWalletCoinEnum.WALLETCONTRACT.getValue(), walletContract);
- map.put(MemberWalletCoinEnum.WALLETCOINCNY.getValue(), lastTotalBalance.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
- return Result.ok(map);
+ return Result.ok(memberWalletContractInfoVo);
}
@Override
@@ -331,8 +321,8 @@
Long memberId = LoginUserUtils.getAppLoginUser().getId();
String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
-
- return Result.ok(walletContract);
+ BigDecimal availableBalance = walletContract.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN);
+ return Result.ok(availableBalance);
}
@Override
@@ -342,26 +332,50 @@
MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
BigDecimal availableBalance = walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN);
- walletCoin.setAvailableBalance(availableBalance);
- return Result.ok(walletCoin);
+ return Result.ok(availableBalance);
}
@Override
public Result getWalletCoinRecords() {
//获取用户ID
Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
List<MemberAccountMoneyChange> coinRecordList = memberAccountMoneyChangeDao.selectWalletCoinRecordsByMemIdTypeSymbol(memberId);
- return Result.ok(coinRecordList);
+ List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>();
+ if(CollUtil.isNotEmpty(coinRecordList)) {
+ for(MemberAccountMoneyChange memberAccountMoneyChange : coinRecordList) {
+ MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo();
+ memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount());
+ memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent());
+ memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus());
+ memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol());
+ memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType());
+ arrayList.add(memberAccountMoneyChangeInfoVo);
+ }
+ }
+ return Result.ok(arrayList);
}
@Override
- public Result getWalletContractRecords(String symbol) {
+ public Result getWalletContractRecords() {
//获取用户ID
Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
+ String symbol = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
List<MemberAccountMoneyChange> contractRecordList = memberAccountMoneyChangeDao.selectWalletContractRecordsByMemIdTypeSymbol(symbol,memberId);
- return Result.ok(contractRecordList);
+
+ List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>();
+ if(ObjectUtil.isNotNull(contractRecordList)) {
+ for(MemberAccountMoneyChange memberAccountMoneyChange : contractRecordList) {
+ MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo();
+ memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount());
+ memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent());
+ memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus());
+ memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol());
+ memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType());
+ arrayList.add(memberAccountMoneyChangeInfoVo);
+ }
+ }
+
+ return Result.ok(arrayList);
}
@Override
@@ -371,7 +385,20 @@
List<MemberAccountMoneyChange> contractRecordList =
memberAccountMoneyChangeDao.selectWalletAgentRecordByMemIdTypeSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue(),memberId);
- return Result.ok(contractRecordList);
+
+ List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>();
+ if(ObjectUtil.isNotNull(contractRecordList)) {
+ for(MemberAccountMoneyChange memberAccountMoneyChange : contractRecordList) {
+ MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo();
+ memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount());
+ memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent());
+ memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus());
+ memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol());
+ memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType());
+ arrayList.add(memberAccountMoneyChangeInfoVo);
+ }
+ }
+ return Result.ok(arrayList);
}
@Override
@@ -472,15 +499,12 @@
CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne();
BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
-
BigDecimal multiply = availableBalance.multiply(cnyUsdt);
- walletAgent.setAvailableBalance(availableBalance);
- Map<String,Object> map = new HashMap<String, Object>();
- map.put(MemberWalletCoinEnum.WALLETCOINUSDT.getValue(), availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
- map.put(MemberWalletCoinEnum.WALLETAGENT.getValue(), walletAgent);
- map.put(MemberWalletCoinEnum.WALLETCOINCNY.getValue(), multiply.setScale(4, BigDecimal.ROUND_DOWN));
- return Result.ok(map);
+ MemberWalletAgentInfoVo memberWalletAgentInfoVo = new MemberWalletAgentInfoVo();
+ memberWalletAgentInfoVo.setTotalBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
+ memberWalletAgentInfoVo.setTotalRMBBalance(multiply.setScale(4, BigDecimal.ROUND_DOWN));
+ return Result.ok(memberWalletAgentInfoVo);
}
}
diff --git a/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java b/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
index 0cc1b7a..0be8a3b 100644
--- a/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
+++ b/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
@@ -85,9 +85,18 @@
@ApiOperation(value = "根据Id查询用户信息", notes = "根据Id查询用户信息")
@GetMapping(value = "/findById/{id}")
- public Result findById(@PathVariable(value = "id") Long id) {
+ public Result findById(@ApiParam(name = "id", value = "用户ID", required = true, example = "1") @PathVariable(value = "id") Long id) {
TestUserEntity testUserEntity = testUserService.getById(id);
TestUserVo testUserVo = TestUserEntityMapper.INSTANCE.entityToVo(testUserEntity);
return Result.ok("success", testUserVo);
}
+
+ @ApiOperation(value = "根据Id查询用户信息", notes = "根据Id查询用户信息")
+ @GetMapping(value = "/findByIdAndName/{id}/{name}")
+ public Result findByIdAndName(@ApiParam(name = "id", value="用户ID", required = true, example = "1") @PathVariable(value = "id") Long id,
+ @ApiParam(name = "name", value="用户姓名", required = true, example = "wzy") @PathVariable(value = "name") String name) {
+ log.info("---->{}", id);
+ log.info("----<{}", name);
+ return Result.ok("success");
+ }
}
diff --git a/src/main/java/com/xcong/excoin/rabbit/consumer/TestConsumer.java b/src/main/java/com/xcong/excoin/rabbit/consumer/TestConsumer.java
new file mode 100644
index 0000000..aea3c07
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/rabbit/consumer/TestConsumer.java
@@ -0,0 +1,21 @@
+package com.xcong.excoin.rabbit.consumer;
+
+import com.xcong.excoin.configurations.RabbitMqConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author wzy
+ * @date 2020-05-25
+ **/
+@Slf4j
+@Component
+public class TestConsumer {
+
+
+ @RabbitListener(queues = RabbitMqConfig.QUEUE_TEST)
+ public void doSomething(String content) {
+ log.info("#---->{}#", content);
+ }
+}
diff --git a/src/main/java/com/xcong/excoin/rabbit/producer/TestProducer.java b/src/main/java/com/xcong/excoin/rabbit/producer/TestProducer.java
new file mode 100644
index 0000000..00ffd52
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/rabbit/producer/TestProducer.java
@@ -0,0 +1,42 @@
+package com.xcong.excoin.rabbit.producer;
+
+import cn.hutool.core.util.IdUtil;
+import com.xcong.excoin.configurations.RabbitMqConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.connection.CorrelationData;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author wzy
+ * @date 2020-05-25
+ **/
+@Slf4j
+@Component
+public class TestProducer implements RabbitTemplate.ConfirmCallback {
+
+ private RabbitTemplate rabbitTemplate;
+
+ @Autowired
+ public TestProducer(RabbitTemplate rabbitTemplate) {
+ this.rabbitTemplate = rabbitTemplate;
+ rabbitTemplate.setConfirmCallback(this);
+ }
+
+ public void sendTestMsg(String content) {
+ CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID());
+ rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_ONE, RabbitMqConfig.ROUTING_KEY_TEST, content, correlationData);
+ }
+
+
+ @Override
+ public void confirm(CorrelationData correlationData, boolean ack, String cause) {
+ log.info("#----->{}#", correlationData);
+ if (ack) {
+ log.info("success");
+ } else {
+ log.info("--->{}", cause);
+ }
+ }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 820acc1..8a849c0 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -69,6 +69,21 @@
min-idle: 8
## 连接超时时间(毫秒)
timeout: 30000
+ rabbitmq:
+ host: 120.27.238.55
+ port: 5672
+ username: ct_rabbit
+ password: 123456
+ publisher-confirm-type: correlated
+
+
+#custom:
+# rabbitmq:
+# host: 120.27.238.55
+# port: 5672
+# username: ct_rabbit
+# password: 123456
+
mybatis-plus:
mapper-locations: classpath:mapper/**/*.xml
diff --git a/src/test/java/com/xcong/excoin/RSATest.java b/src/test/java/com/xcong/excoin/RSATest.java
index 4d4d3b6..45c6488 100644
--- a/src/test/java/com/xcong/excoin/RSATest.java
+++ b/src/test/java/com/xcong/excoin/RSATest.java
@@ -13,6 +13,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
+import java.math.BigDecimal;
import java.security.KeyPair;
/**
@@ -101,4 +102,10 @@
String md5str = SecureUtil.md5("123456");
log.info("{}", md5str);
}
+
+ @Test
+ public void bigdecimalTest() {
+ BigDecimal bigDecimal = new BigDecimal("123.12345678").setScale(4, BigDecimal.ROUND_DOWN);
+ log.info("--->{}", bigDecimal);
+ }
}
diff --git a/src/test/java/com/xcong/excoin/RabbitMqTest.java b/src/test/java/com/xcong/excoin/RabbitMqTest.java
new file mode 100644
index 0000000..82b668b
--- /dev/null
+++ b/src/test/java/com/xcong/excoin/RabbitMqTest.java
@@ -0,0 +1,24 @@
+package com.xcong.excoin;
+
+import com.xcong.excoin.rabbit.producer.TestProducer;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+
+/**
+ * @author wzy
+ * @date 2020-05-25
+ **/
+@SpringBootTest
+public class RabbitMqTest {
+
+ @Autowired
+ private TestProducer testProducer;
+
+ @Test
+ public void sendTestMsg() {
+ testProducer.sendTestMsg("this is test msg");
+ }
+}
--
Gitblit v1.9.1