From f812dd42487c1ee47cb9bcbeed1f40779bbae6aa Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Thu, 15 Oct 2020 20:09:04 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 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 892309d..ea52af3 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
@@ -382,7 +382,13 @@
BigDecimal nowPriceinBigDecimal = price;
//查询当前价
- //BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
+ BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
+ BigDecimal subPrice = nowPrice.multiply(BigDecimal.valueOf(0.2));
+ BigDecimal minPrice = nowPrice.subtract(subPrice);
+ BigDecimal maxPrice = nowPrice.add(subPrice);
+ if (nowPriceinBigDecimal.compareTo(minPrice) < 0 || nowPriceinBigDecimal.compareTo(maxPrice) > 0) {
+ return Result.fail("请输入合适的价格");
+ }
// 获取交易管理的杠杠倍率,手续费率等信息,由平台进行设置
symbol = symbol.toUpperCase();
@@ -413,6 +419,19 @@
closingPrice = price.multiply(amount).multiply(tradeSetting.getCoinFeeRatio());
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%");
+ }
+ }
} else {
// 市价
if (OrderCoinsEntity.ORDERTYPE_BUY == type) {
--
Gitblit v1.9.1