zainali5120
2020-10-21 51ce8b8a4c2b9620abb0e22d1a0c8612300094b3
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());
                            }
                        }
                    }