From 0c276f7836257053aa77309c40199bd4ce3a0612 Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Thu, 15 Oct 2020 20:08:01 +0800
Subject: [PATCH] modify

---
 src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 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 9217ffa..6878fc1 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
@@ -383,12 +383,15 @@
         BigDecimal nowPriceinBigDecimal = price;
         //查询当前价
         BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
+<<<<<<< HEAD
         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("请输入合适的价格");
         }
+=======
+>>>>>>> feature/撮合交易
 
         // 获取交易管理的杠杠倍率,手续费率等信息,由平台进行设置
         symbol = symbol.toUpperCase();
@@ -419,6 +422,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