| | |
| | | MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeEnum.USDT.name()); |
| | | |
| | | PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting(); |
| | | |
| | | |
| | | Long id = memberEntity.getId(); |
| | | MemberEntity selectById = memberDao.selectById(id); |
| | | BigDecimal spread = selectById.getSpread(); |
| | |
| | | holdOrderEntity.setIsCanClosing(ContractHoldOrderEntity.ORDER_CAN_CLOSING_Y); |
| | | holdOrderEntity.setPrePaymentAmount(prePaymentAmount); |
| | | holdOrderEntity.setBondAmount(bondAmount.add(openFeePrice)); |
| | | holdOrderEntity.setOperateNo(1); |
| | | |
| | | ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity); |
| | | contractOrderEntity.setOpeningTime(new Date()); |
| | |
| | | |
| | | if (i > 0) { |
| | | memberWalletContractDao.increaseWalletContractBalanceById(prePaymentAmount.negate(), openFeePrice.negate(), null, walletContract.getId()); |
| | | |
| | | // 发送爆仓消息 |
| | | sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol()); |
| | | |
| | | // 计算佣金 |
| | | ThreadPoolUtils.calReturnMoney(memberEntity.getId(), contractOrderEntity.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN); |
| | | |
| | |
| | | int i = contractHoldOrderDao.updateById(holdOrderEntity); |
| | | |
| | | if (i > 0) { |
| | | OrderModel model = null; |
| | | // 开多 |
| | | if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | // 开空 |
| | | } else { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | } |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | // 发送爆仓消息 |
| | | sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol()); |
| | | return Result.ok("调整成功"); |
| | | } |
| | | return Result.fail("调整失败"); |
| | |
| | | holdOrderEntity.setOperateNo(holdOrderEntity.getOperateNo() + 1); |
| | | contractHoldOrderDao.updateById(holdOrderEntity); |
| | | |
| | | OrderModel model = null; |
| | | // 开多 |
| | | if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), newForcePrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | // 开空 |
| | | } else { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), newForcePrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | } |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | // 发送爆仓消息 |
| | | sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), newForcePrice, holdOrderEntity.getSymbol()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol) { |
| | | OrderModel model = null; |
| | | // 开多 |
| | | if (ContractHoldOrderEntity.OPENING_TYPE_MORE == type) { |
| | | model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol); |
| | | // 开空 |
| | | } else { |
| | | model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol); |
| | | } |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } |