Helius
2021-06-04 2e57ef64fed2e9c12cc7d673c31624a06bc0efe2
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java
@@ -32,6 +32,7 @@
import com.xcong.excoin.modules.otc.vo.BuyOrderDetailVo;
import com.xcong.excoin.modules.otc.vo.OrderListVo;
import com.xcong.excoin.modules.otc.vo.SaleOrderDetailVo;
import com.xcong.excoin.rabbit.producer.OtcProducter;
import com.xcong.excoin.utils.RedisUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -57,6 +58,7 @@
    private final OtcBlackListDao otcBlackListDao;
    private final OtcSettingDao otcSettingDao;
    private final RedisUtils redisUtils;
    private final OtcProducter otcProducter;
    @Override
@@ -97,8 +99,9 @@
            throw new GlobalException("剩余数量不足");
        }
        BigDecimal cny = orderAddDto.getUsdtAmount().multiply(entrustOrder.getUnitPrice());
        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("数量与金额不符");
        }
        /**
@@ -199,7 +202,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("数量与金额不符");
        }
@@ -315,6 +319,7 @@
        memberWalletCoinDao.reduceFrozenBalance(saleWallet.getId(), buyOrder.getCoinAmount());
        this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_FINISH, null, otcOrder.getOrderNo());
        otcProducter.sendMarketBussinessMsg(otcOrder.getEntrustOrderId(), OtcOrder.STATUS_FINISH);
    }
    @Override
@@ -338,7 +343,7 @@
        buyDetail.setTotalAmount(buyOrder.getTotalAmount());
        buyDetail.setUnitPrice(buyOrder.getUnitPrice());
        buyDetail.setCreateTime(buyOrder.getCreateTime());
        buyDetail.setIsMb(member.getIsTrader());
        buyDetail.setIsMb(member.getAccountType() == 1 ? 2 : 1);
        buyDetail.setPayName(buyOrder.getPayName());
        buyDetail.setIsOwnEntrust(member.getId().equals(buyOrder.getEntrustMemberId()) ? 1 : 2);
@@ -399,7 +404,7 @@
        saleDetail.setTotalAmount(saleOrder.getTotalAmount());
        saleDetail.setUnitPrice(saleOrder.getUnitPrice());
        saleDetail.setCreateTime(saleOrder.getCreateTime());
        saleDetail.setIsMb(member.getIsTrader());
        saleDetail.setIsMb(member.getAccountType() == 1 ? 2 : 1);
        saleDetail.setPayName(saleOrder.getPayName());
        saleDetail.setSaleName(buyMember.getName());
@@ -464,6 +469,8 @@
        otcEntrustOrderDao.updateRemainAmount(otcOrder.getEntrustOrderId(), otcOrder.getCoinAmount());
        this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_CANCEL, null, otcOrder.getOrderNo());
        otcProducter.sendMarketBussinessMsg(otcOrder.getEntrustOrderId(), OtcOrder.STATUS_CANCEL);
    }
    @Override