| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void dealEntrustCoinOrder() {
|
| | | List<String> ignoreTypes = new ArrayList<>();
|
| | | ignoreTypes.add(SymbolsConstats.ROC);
|
| | | ignoreTypes.add(SymbolsConstats.CPV);
|
| | | List<OrderCoinsEntity> list = orderCoinsDao.selectAllEntrustingCoinOrderList(ignoreTypes);
|
| | | if (CollUtil.isNotEmpty(list)) {
|
| | | for (OrderCoinsEntity orderCoinsEntity : list) {
|
| | |
| | | memberAccountFlowEntityDao.insert(recordSell);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void initOrders(String symbol, Integer type, Integer tradeType, BigDecimal price,
|
| | | BigDecimal amount, BigDecimal entrustAmount) {
|
| | | //获取用户ID
|
| | | Long memberId = 10L;
|
| | | BigDecimal nowPriceinBigDecimal = price;
|
| | | //查询当前价
|
| | | //BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
|
| | |
|
| | | // 获取交易管理的杠杠倍率,手续费率等信息,由平台进行设置
|
| | | symbol = symbol.toUpperCase();
|
| | |
|
| | | // 手续费用(手续费=建仓价X数量X手续费率)
|
| | | BigDecimal closingPrice = BigDecimal.ZERO;
|
| | |
|
| | | // BigDecimal totalPayPricCoin = nowPrice.multiply(amount).add(closingPrice);
|
| | | // 首先将单插入到数据库主表(委托表)
|
| | | // 创建订单
|
| | | OrderCoinsEntity order = new OrderCoinsEntity();
|
| | | //根据委托类型生成不同数据
|
| | | // 如果是限价交易直接插入主表数据
|
| | | order.setMemberId(memberId);
|
| | | order.setOrderNo(generateSimpleSerialno(memberId.toString()));
|
| | | order.setOrderType(type);
|
| | | order.setSymbol(symbol);
|
| | | //order.setMarkPrice(nowPrice);
|
| | |
|
| | | // 成交量 先设置为0
|
| | | order.setDealCnt(BigDecimal.ZERO);
|
| | | // 成交价
|
| | | //order.setDealPrice(price);
|
| | | // 成交金额
|
| | | order.setDealAmount(BigDecimal.ZERO);
|
| | | order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DODING);
|
| | | order.setTradeType(tradeType);
|
| | | // 手续费
|
| | | order.setFeeAmount(closingPrice);
|
| | | if (OrderCoinsEntity.TRADETYPE_FIXEDPRICE.equals(tradeType)) {
|
| | | // 限价 是需要价格和数量 可以得到成交金额
|
| | | // 下单量
|
| | | order.setEntrustCnt(amount);
|
| | | // 下单价格
|
| | | order.setEntrustPrice(price);
|
| | | order.setEntrustAmount(amount.multiply(price));
|
| | | } else {
|
| | | if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
|
| | | // 市价 只有金额
|
| | | order.setEntrustAmount(entrustAmount);
|
| | | } else {
|
| | | // 下单量
|
| | | order.setEntrustCnt(amount);
|
| | | // 下单价格
|
| | | order.setEntrustPrice(price);
|
| | | order.setEntrustAmount(amount.multiply(price));
|
| | | }
|
| | |
|
| | | }
|
| | | orderCoinsDao.insert(order);
|
| | | // 加入到撮合
|
| | | CoinTrader trader = factory.getTrader(symbol);
|
| | | trader.trade(order);
|
| | | }
|
| | |
|
| | | }
|