| | |
| | | import com.xcong.excoin.common.enumerates.RabbitPriceTypeEnum; |
| | | import com.xcong.excoin.common.response.Result; |
| | | import com.xcong.excoin.common.system.service.CommonService; |
| | | import com.xcong.excoin.modules.coin.service.CoinService; |
| | | import com.xcong.excoin.modules.contract.dao.ContractEntrustOrderDao; |
| | | import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao; |
| | | import com.xcong.excoin.modules.contract.dao.ContractOrderDao; |
| | |
| | | @Autowired |
| | | private FollowProducer followProducer; |
| | | |
| | | @Autowired |
| | | private CoinService coinService; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Result submitOrder(SubmitOrderDto submitOrderDto) { |
| | |
| | | return Result.loading("loading_type"); |
| | | } |
| | | |
| | | BigDecimal total = coinService.getAllWalletAmount(memberIdLong); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | if (total.compareTo(AppContants.BASE_MIN_AMOUNT) > 0) { |
| | | data.put("baseUrl", AppContants.BASE_URL_L2); |
| | | } else { |
| | | data.put("baseUrl", AppContants.BASE_URL_L1); |
| | | } |
| | | |
| | | // 判断当前对应的持仓/委托 |
| | | if (memberEntity.getContractPositionType() == ContractEntrustOrderEntity.POSITION_TYPE_ADD) { |
| | | List<ContractHoldOrderEntity> holdList = contractHoldOrderDao.selectMemberHoldOrderByPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ALL, memberEntity.getId()); |
| | |
| | | } |
| | | |
| | | // 逐仓逻辑 |
| | | return doPositionTypeForAdd(submitOrderDto, memberEntity); |
| | | Result result = doPositionTypeForAdd(submitOrderDto, memberEntity); |
| | | result.setData(data); |
| | | return result; |
| | | } else { |
| | | List<ContractHoldOrderEntity> holdList = contractHoldOrderDao.selectMemberHoldOrderByPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ADD, memberEntity.getId()); |
| | | List<ContractEntrustOrderEntity> entrustList = contractEntrustOrderDao.selectMemberEntrustOrderByPositionType(ContractEntrustOrderEntity.POSITION_TYPE_ADD, memberEntity.getId()); |
| | |
| | | } |
| | | |
| | | // 全仓逻辑 |
| | | return doPositionTypeForWhole(submitOrderDto, memberEntity); |
| | | Result result = doPositionTypeForWhole(submitOrderDto, memberEntity); |
| | | result.setData(data); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | holdOrderListVo.setReturnRate(returnRate); |
| | | holdOrderListVo.setProfitOrLoss(rewardRatio); |
| | | if (ContractEntrustOrderEntity.POSITION_TYPE_ALL == memberEntity.getContractPositionType()) { |
| | | BigDecimal forcePrice = CalculateUtil.calWholePriceTwo(memberEntity, holdOrderEntity, 1, newPrice); |
| | | BigDecimal forcePrice = CalculateUtil.calWholePriceTwo(memberEntity, holdOrderEntity, 1); |
| | | // contractHoldOrderDao.updateForcePriceBySymbolAndMemberId(forcePrice, memberEntity.getId(), holdOrderEntity.getSymbol()); |
| | | holdOrderListVo.setForceClosingPrice(forcePrice); |
| | | } |