| | |
| | | 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 com.xcong.excoin.utils.ThreadPoolUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.annotation.Bean; |
| | |
| | | private final OtcBlackListDao otcBlackListDao; |
| | | private final OtcSettingDao otcSettingDao; |
| | | private final RedisUtils redisUtils; |
| | | private final OtcProducter otcProducter; |
| | | |
| | | |
| | | @Override |
| | |
| | | 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) { |
| | | log.info("BUY = CNY:{}, CNY_{}, USDT:{}, USDT_{}", cny, orderAddDto.getCnyAmount(), usdt, orderAddDto.getUsdtAmount()); |
| | | throw new GlobalException("数量与金额不符"); |
| | | } |
| | | /** |
| | |
| | | this.baseMapper.insert(otcOrder); |
| | | this.baseMapper.insert(sale); |
| | | |
| | | ThreadPoolUtils.sendOrderMsg(); |
| | | return Result.ok("购买成功", otcOrder.getId()); |
| | | } |
| | | |
| | |
| | | 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) { |
| | | log.info("SALE = CNY:{}, CNY_{}, USDT:{}, USDT_{}", cny, orderAddDto.getCnyAmount(), usdt, orderAddDto.getUsdtAmount()); |
| | | throw new GlobalException("数量与金额不符"); |
| | | } |
| | | |
| | |
| | | this.baseMapper.insert(buy); |
| | | |
| | | memberWalletCoinDao.updateFrozenBalance(member.getId(), wallet.getId(), orderAddDto.getUsdtAmount()); |
| | | |
| | | ThreadPoolUtils.sendOrderMsg(); |
| | | return Result.ok("出售成功", otcOrder.getId()); |
| | | } |
| | | |
| | |
| | | memberWalletCoinDao.reduceFrozenBalance(saleWallet.getId(), buyOrder.getCoinAmount()); |
| | | |
| | | this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_FINISH, null, otcOrder.getOrderNo()); |
| | | otcProducter.sendMarketBussinessMsg(otcOrder.getEntrustOrderId(), OtcOrder.STATUS_FINISH); |
| | | otcProducter.sendOrderReturn(buyOrder.getOrderNo()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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); |
| | | |
| | |
| | | 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()); |
| | |
| | | |
| | | otcEntrustOrderDao.updateRemainAmount(otcOrder.getEntrustOrderId(), otcOrder.getCoinAmount()); |
| | | this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_CANCEL, null, otcOrder.getOrderNo()); |
| | | |
| | | otcProducter.sendMarketBussinessMsg(otcOrder.getEntrustOrderId(), OtcOrder.STATUS_CANCEL); |
| | | } |
| | | |
| | | @Override |