| | |
| | | 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(multiply.compareTo(totalAmount) < 0) { |
| | | throw new GlobalException("可用金额不足"); |
| | | } |
| | | |
| | | memberWalletCoinDao.updateFrozenBalance(member.getId(), coinWallet.getId(), addDto.getAmount()); |
| | | } |
| | | |
| | | OtcMarketBussiness mb = otcMarketBussinessDao.selectMarketBussinessByMemberId(member.getId()); |
| | | if (mb == null) { |
| | | OtcMarketBussiness otcMb = new OtcMarketBussiness(); |
| | | otcMb.setMemberId(member.getId()); |
| | | otcMb.setAvgCoinTime(0); |
| | | otcMb.setAvgPayTime(0); |
| | | otcMb.setTotalOrderCnt(0); |
| | | otcMb.setBuyCnt(0); |
| | | otcMb.setFinishRatio(BigDecimal.ZERO); |
| | | otcMb.setStatus(OtcMarketBussiness.CHECK_PASS); |
| | | otcMarketBussinessDao.insert(otcMb); |
| | | if (!MemberEntity.IS_TRADER_Y.equals(member.getIsTrader())) { |
| | | throw new GlobalException("不是市商"); |
| | | } |
| | | |
| | | if (member.getIsTrader() == 2) { |