Helius
2021-05-28 af8558dd3376fa2ac0674a9b9792aecb7a00342f
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java
@@ -2,6 +2,7 @@
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -32,12 +33,15 @@
import com.xcong.excoin.modules.otc.vo.EntrustListVo;
import com.xcong.excoin.modules.otc.vo.EntrustOrderDetailVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import netscape.javascript.JSObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor
public class OtcEntrustOrderServiceImpl extends ServiceImpl<OtcEntrustOrderDao, OtcEntrustOrder> implements OtcEntrustOrderService {
@@ -70,13 +74,14 @@
        BigDecimal totalAmount = addDto.getUnitPrice().multiply(addDto.getAmount());
        otcEntrustOrder.setTotalAmount(totalAmount);
        if (addDto.getMax().compareTo(totalAmount) < 0) {
        if (totalAmount.compareTo(addDto.getMax()) < 0) {
            throw new GlobalException("最大限额应小于总金额");
        }
        if (OtcEntrustOrder.ORDER_TYPE_S.equals(addDto.getType())) {
            MemberWalletCoinEntity coinWallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT");
            if(coinWallet.getAvailableBalance().compareTo(totalAmount) < 0) {
//            BigDecimal multiply = addDto.getUnitPrice().multiply(coinWallet.getAvailableBalance());
            if(coinWallet.getAvailableBalance().compareTo(addDto.getAmount()) < 0) {
                throw new GlobalException("可用金额不足");
            }
@@ -191,7 +196,7 @@
        if (OtcEntrustOrder.ORDER_TYPE_S.equals(otcEntrustOrder.getOrderType())) {
            MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT");
            memberWalletCoinDao.subFrozenBalance(member.getId(), wallet.getId(), wallet.getFrozenBalance());
            memberWalletCoinDao.subFrozenBalance(member.getId(), wallet.getId(), otcEntrustOrder.getRemainCoinAmount());
        }
        otcEntrustOrder = new OtcEntrustOrder();