Helius
2021-06-08 30c1c9d16a57d2bbc7cd1511d02c5ddcc6a143f6
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java
@@ -34,6 +34,7 @@
import com.xcong.excoin.modules.otc.vo.SaleOrderDetailVo;
import com.xcong.excoin.rabbit.producer.OtcProducter;
import com.xcong.excoin.utils.RedisUtils;
import com.xcong.excoin.utils.ThreadPoolUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
@@ -99,8 +100,9 @@
            throw new GlobalException("剩余数量不足");
        }
        BigDecimal cny = orderAddDto.getUsdtAmount().multiply(entrustOrder.getUnitPrice()).setScale(2,BigDecimal.ROUND_DOWN);;
        if (cny.compareTo(orderAddDto.getCnyAmount()) != 0) {
        BigDecimal cny = orderAddDto.getUsdtAmount().multiply(entrustOrder.getUnitPrice()).setScale(2, BigDecimal.ROUND_DOWN);
        BigDecimal usdt = orderAddDto.getCnyAmount().divide(entrustOrder.getUnitPrice(), 2, BigDecimal.ROUND_DOWN);
        if (cny.compareTo(orderAddDto.getCnyAmount()) != 0 && usdt.compareTo(orderAddDto.getUsdtAmount()) != 0) {
            throw new GlobalException("数量与金额不符");
        }
        /**
@@ -152,6 +154,7 @@
        this.baseMapper.insert(otcOrder);
        this.baseMapper.insert(sale);
        ThreadPoolUtils.sendOrderMsg();
        return Result.ok("购买成功", otcOrder.getId());
    }
@@ -201,7 +204,8 @@
        }
        BigDecimal cny = orderAddDto.getUsdtAmount().multiply(entrustOrder.getUnitPrice());
        if (cny.compareTo(orderAddDto.getCnyAmount()) != 0) {
        BigDecimal usdt = orderAddDto.getCnyAmount().divide(entrustOrder.getUnitPrice(), 2, BigDecimal.ROUND_DOWN);
        if (cny.compareTo(orderAddDto.getCnyAmount()) != 0 && usdt.compareTo(orderAddDto.getUsdtAmount()) != 0) {
            throw new GlobalException("数量与金额不符");
        }
@@ -248,6 +252,8 @@
        this.baseMapper.insert(buy);
        memberWalletCoinDao.updateFrozenBalance(member.getId(), wallet.getId(), orderAddDto.getUsdtAmount());
        ThreadPoolUtils.sendOrderMsg();
        return Result.ok("出售成功", otcOrder.getId());
    }
@@ -318,6 +324,7 @@
        this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_FINISH, null, otcOrder.getOrderNo());
        otcProducter.sendMarketBussinessMsg(otcOrder.getEntrustOrderId(), OtcOrder.STATUS_FINISH);
        otcProducter.sendOrderReturn(buyOrder.getOrderNo());
    }
    @Override