zainali5120
2020-11-29 e3871a95021252537022d6c4db795d393a9f17bb
卖出额度限制
1 files modified
8 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java 8 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -463,12 +463,16 @@
                String yyyyMMdd = DateUtil.dateToString(new Date(), "yyyyMMdd");
                String persentKey = String.format(LIMIT_SELL_PERSENT_KEY,yyyyMMdd,memberId.toString());
                BigDecimal aviSell  =BigDecimal.ZERO;
                if(StringUtils.isBlank(persentKey)){
                String string = redisUtils.getString(persentKey);
                if(StringUtils.isBlank(string)){
                    // 当日可以卖的数量
                     aviSell = spread.divide(PERSENT,4, RoundingMode.HALF_UP).multiply(availableBalance);
                }else{
                    aviSell = new BigDecimal(string);
                }
                if(aviSell.compareTo(amount)<0){
                    return Result.fail("卖出超过上限"+spread+"%");
                    return Result.fail("卖出超过上限"+spread.setScale(0,RoundingMode.HALF_UP)+"%");
                }
                aviSell = aviSell.subtract(amount);
                // 设置