| | |
| | | contractOrderEntity.setOpeningTime(new Date()); |
| | | contractHoldOrderDao.insert(holdOrderEntity); |
| | | int i = contractOrderDao.insert(contractOrderEntity); |
| | | |
| | | if (i > 0) { |
| | | memberWalletContractDao.increaseWalletContractBalanceById(prePaymentAmount.negate(), openFeePrice.negate(), null, walletContract.getId()); |
| | | // 计算佣金 |
| | | ThreadPoolUtils.calReturnMoney(memberEntity.getId(), contractOrderEntity.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN); |
| | | |
| | | // 插入财务流水 |
| | | if (submitOrderDto.getOrderType() == ContractHoldOrderEntity.OPENING_TYPE_MORE) { |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), prePaymentAmount, walletContract.getAvailableBalance().subtract(prePaymentAmount), submitOrderDto.getSymbol(), "买涨持仓", "买涨:" + submitOrderDto.getSymbol()); |
| | | } else { |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), prePaymentAmount, walletContract.getAvailableBalance().subtract(prePaymentAmount), submitOrderDto.getSymbol(), "买跌持仓", "买跌:" + submitOrderDto.getSymbol()); |
| | | } |
| | | return Result.ok("提交成功"); |
| | | } |
| | | return Result.fail("提交失败"); |
| | |
| | | // 开多止盈 |
| | | if (stopProfitPrice != null) { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | // 开多止损 |
| | | if (stopLessPrice != null) { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } else { |
| | | // 开空止盈 |
| | | if (stopProfitPrice != null) { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | // 开空止损 |
| | | if (stopLessPrice != null) { |
| | | model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | } |
| | | } |
| | | producer.sendPriceOperate(JSONObject.toJSONString(model)); |
| | | return Result.ok("设置成功"); |
| | | } |
| | | return Result.fail("设置失败"); |