From 066139a0179cf9760abffae650ca0ffef1976fcb Mon Sep 17 00:00:00 2001
From: zainali5120 <512061637@qq.com>
Date: Mon, 19 Oct 2020 10:20:01 +0800
Subject: [PATCH] 优化卖出限制,使用redis配置进行控制
---
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java | 37 +++++++++++++++++++------------------
src/main/resources/application.yml | 2 +-
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
index b59e970..d5ce636 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -381,7 +381,11 @@
// return Result.fail("买入额度受限");
// }
} else {
- return Result.fail("卖出受限");
+ // 判断redis开关
+ String string = redisUtils.getString("SELL_LIMIT_KEY");
+ if (StringUtils.isNotBlank(string)) {
+ return Result.fail("卖出受限");
+ }
}
}
@@ -419,18 +423,15 @@
totalPayPrice = price.multiply(amount).add(closingPrice);
entrustAmount = price.multiply(amount);
// 限价买不能高于当前10%
- if (OrderCoinsEntity.ORDERTYPE_BUY == type) {
- BigDecimal multiply = nowPrice.multiply(new BigDecimal("1.2"));
- if(price.compareTo(multiply)>0){
- return Result.fail("不能高于当前价的120%");
- }
- }else{
- // 卖不能小于当前90
- BigDecimal multiply = nowPrice.multiply(new BigDecimal("0.8"));
- if(price.compareTo(multiply)<0){
- return Result.fail("不能低于当前价的80%");
- }
+ BigDecimal multiply = nowPrice.multiply(new BigDecimal("1.2"));
+ if (price.compareTo(multiply) > 0) {
+ return Result.fail("不能高于当前价的120%");
}
+ multiply= nowPrice.multiply(new BigDecimal("0.8"));
+ if (price.compareTo(multiply) < 0) {
+ return Result.fail("不能低于当前价的80%");
+ }
+
} else {
// 市价
if (OrderCoinsEntity.ORDERTYPE_BUY == type) {
@@ -1095,19 +1096,19 @@
if (CollectionUtils.isNotEmpty(trades)) {
for (OrderCoinsEntity trade : trades) {
if (trade != null) {
- if (trade.getOrderType()==2 && trade.getEntrustCnt().compareTo(trade.getDealCnt())!=0){
- System.out.println("问题卖单:"+ JSON.toJSONString(trade));
+ if (trade.getOrderType() == 2 && trade.getEntrustCnt().compareTo(trade.getDealCnt()) != 0) {
+ System.out.println("问题卖单:" + JSON.toJSONString(trade));
}
//orderCoinsDao.updateStatus(trade.getId(),OrderCoinsEntity.ORDERSTATUS_DONE);
ids.add(trade.getId());
// 买单 实际成交金额小于委托的 这一部分从冻结扣除
- if(OrderCoinsEntity.ORDERTYPE_BUY==trade.getOrderType()){
- if(trade.getEntrustAmount().compareTo(trade.getDealAmount())>0){
+ if (OrderCoinsEntity.ORDERTYPE_BUY == trade.getOrderType()) {
+ if (trade.getEntrustAmount().compareTo(trade.getDealAmount()) > 0) {
// 此时退回这部分的差额
BigDecimal subtract = trade.getEntrustAmount().subtract(trade.getDealAmount());
MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(trade.getMemberId(), CoinTypeEnum.USDT.name());
- if(memberWalletCoinEntity!=null){
- coinService.updateWalletBalance(memberWalletCoinEntity.getId(),subtract,null,subtract.negate());
+ if (memberWalletCoinEntity != null) {
+ coinService.updateWalletBalance(memberWalletCoinEntity.getId(), subtract, null, subtract.negate());
}
}
}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index d7ba143..4a0fe1f 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -5,7 +5,7 @@
spring:
profiles:
- active: test
+ active: dayline
datasource:
url: jdbc:mysql://rm-bp1i2g5rg5dubo9s40o.mysql.rds.aliyuncs.com:3306/db_roc?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
username: roc_user
--
Gitblit v1.9.1