|  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  | 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 { | 
 |  |  | 
 |  |  |         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("可用金额不足"); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |         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(); |