| | |
| | | |
| | | // 发送委托单队列消息 |
| | | if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) { |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol()); |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买涨", "买涨:" + submitEntrustDto.getSymbol()); |
| | | } else { |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol()); |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买跌", "买跌:" + submitEntrustDto.getSymbol()); |
| | |
| | | |
| | | MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeConvert.convertContractTypeToCoin(submitEntrustDto.getSymbol())); |
| | | |
| | | ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectWholeHoldOrderByOrderType(memberEntity.getId(), submitEntrustDto.getEntrustType()); |
| | | ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectWholeHoldOrderByOrderType(memberEntity.getId(), submitEntrustDto.getEntrustType(), submitEntrustDto.getSymbol()); |
| | | |
| | | BigDecimal bondAmount; |
| | | BigDecimal openFeePrice; |
| | |
| | | |
| | | // 发送委托单队列消息 |
| | | if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) { |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol()); |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买涨", "买涨:" + submitEntrustDto.getSymbol()); |
| | | } else { |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol()); |
| | | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买跌", "买跌:" + submitEntrustDto.getSymbol()); |
| | |
| | | ContractOrderEntity orderEntity = ContractEntrustOrderEntityMapper.INSTANCE.entrustOrderToOrder(entrustOrderEntity); |
| | | orderEntity.setTradeType(ContractOrderEntity.TRADE_TYPE_MARK_PRICE); |
| | | orderEntity.setOrderStatus(ContractOrderEntity.ORDER_STATUS_CANCEL); |
| | | |
| | | if (entrustOrderEntity.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE) { |
| | | orderEntity.setClosingType(RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue()); |
| | | } |
| | | |
| | | if (entrustOrderEntity.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_LESS) { |
| | | orderEntity.setClosingType(RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue()); |
| | | } |
| | | |
| | | int i = contractOrderDao.insert(orderEntity); |
| | | |
| | | contractEntrustOrderDao.deleteById(entrustOrderEntity.getId()); |
| | |
| | | int closeType; |
| | | if (holdOrderEntity.getOpeningType() == ContractHoldOrderEntity.OPENING_TYPE_MORE) { |
| | | // 开多, 若委托价低于当前价则立即成交 |
| | | // if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) <= 0) { |
| | | // WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | // wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | // wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | // return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | // } |
| | | if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) <= 0) { |
| | | WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | } |
| | | |
| | | closeType = ContractOrderEntity.ORDER_TYPE_CLOSE_MORE; |
| | | } else { |
| | | // 开空, 若委托价高于当前价则立即成交 |
| | | // if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) >= 0) { |
| | | // WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | // wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | // wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | // return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | // } |
| | | if (submitCloseEntrustDto.getEntrustPrice().compareTo(newPrice) >= 0) { |
| | | WholeCloseOrderDto wholeCloseOrderDto = new WholeCloseOrderDto(); |
| | | wholeCloseOrderDto.setCount(submitCloseEntrustDto.getSymbolCnt()); |
| | | wholeCloseOrderDto.setId(submitCloseEntrustDto.getId()); |
| | | return contractHoldOrderService.cancelHoldOrder(wholeCloseOrderDto); |
| | | } |
| | | |
| | | closeType = ContractOrderEntity.ORDER_TYPE_CLOSE_LESS; |
| | | } |
| | |
| | | entrustOrder.setLeverRatio(holdOrderEntity.getLeverRatio()); |
| | | entrustOrder.setSymbolSku(holdOrderEntity.getSymbolSku()); |
| | | entrustOrder.setEntrustType(closeType); |
| | | entrustOrder.setSymbolCnt(holdOrderEntity.getSymbolCnt()); |
| | | entrustOrder.setSymbolCnt(submitCloseEntrustDto.getSymbolCnt()); |
| | | entrustOrder.setSymbol(holdOrderEntity.getSymbol()); |
| | | |
| | | int i = contractEntrustOrderDao.insert(entrustOrder); |
| | | |
| | | |
| | | memberWalletContractDao.increaseWalletContractBalanceById(null, null, bondAmount, walletContract.getId()); |
| | | // memberWalletContractDao.increaseWalletContractBalanceById(null, null, bondAmount, walletContract.getId()); |
| | | |
| | | if (i > 0) { |
| | | // 发送委托消息 |
| | | if (holdOrderEntity.getOpeningType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) { |
| | | OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | OrderModel model = new OrderModel(entrustOrder.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } else { |
| | | OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | OrderModel model = new OrderModel(entrustOrder.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } |