KKSU
2024-09-30 36be00e0f3cbe0d559c646fd2977e6e3a74aa6f9
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java
@@ -110,7 +110,6 @@
    public void modify(EntrustOrderAddDto modifyDto) {
        MemberEntity member = LoginUserUtils.getAppLoginUser();
        OtcEntrustOrder otcEntrustOrder = OtcEntrustOrderMapper.INSTANCE.entrustOrderDtoToEntity(modifyDto);
        BigDecimal remainAmount = otcEntrustOrder.getRemainCoinAmount();
        otcEntrustOrder.setMemberId(member.getId());
        otcEntrustOrder.setRemainCoinAmount(modifyDto.getAmount());
@@ -138,16 +137,18 @@
        BigDecimal totalAmount = modifyDto.getUnitPrice().multiply(modifyDto.getAmount());
        otcEntrustOrder.setTotalAmount(totalAmount);
        BigDecimal remainAmount = prevEntity.getRemainCoinAmount();
        if (OtcEntrustOrder.ORDER_TYPE_S.equals(modifyDto.getType())) {
            MemberWalletCoinEntity coinWallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT");
            coinWallet.setAvailableBalance(coinWallet.getAvailableBalance().add(remainAmount));
            if(coinWallet.getAvailableBalance().compareTo(totalAmount) < 0) {
            if(coinWallet.getAvailableBalance().compareTo(modifyDto.getAmount()) < 0) {
                throw new GlobalException("可用金额不足");
            }
            BigDecimal frozen = coinWallet.getFrozenBalance().subtract(remainAmount);
            coinWallet.setAvailableBalance(coinWallet.getAvailableBalance().subtract(totalAmount));
            coinWallet.setFrozenBalance(frozen.add(totalAmount));
            coinWallet.setAvailableBalance(coinWallet.getAvailableBalance().subtract(modifyDto.getAmount()));
            coinWallet.setFrozenBalance(frozen.add(modifyDto.getAmount()));
            memberWalletCoinDao.updateById(coinWallet);
        }