| | |
| | | package com.xcong.excoin.modules.contract.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | |
| | | import com.alibaba.druid.sql.visitor.functions.If; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | |
| | | // 占用保证金 -- 即持仓单中的保证金之和 |
| | | BigDecimal beUsedBondAmount = BigDecimal.ZERO; |
| | | BigDecimal moreBondAmount = BigDecimal.ZERO; |
| | | BigDecimal lessBondAmount = BigDecimal.ZERO; |
| | | // 总盈利 |
| | | BigDecimal totalProfitOrLess = BigDecimal.ZERO; |
| | | if (CollUtil.isNotEmpty(holdOrderEntities)) { |
| | |
| | | BigDecimal profitOrLess = BigDecimal.ZERO; |
| | | // 开多 |
| | | if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) { |
| | | moreBondAmount = moreBondAmount.add(holdOrderEntity.getBondAmount()); |
| | | profitOrLess = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(new BigDecimal(holdOrderEntity.getSymbolCntSale())).multiply(lotNumber); |
| | | // 开空 |
| | | } else { |
| | | lessBondAmount = lessBondAmount.add(holdOrderEntity.getBondAmount()); |
| | | profitOrLess = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(new BigDecimal(holdOrderEntity.getSymbolCntSale())).multiply(lotNumber); |
| | | } |
| | | |
| | |
| | | contractMoneyInfoVo.setUpOrDown(upOrDown); |
| | | contractMoneyInfoVo.setSymbolSku(cacheSettingUtils.getSymbolSku(symbol)); |
| | | contractMoneyInfoVo.setLeverRate(rateEntity.getLevelRateUp()); |
| | | contractMoneyInfoVo.setMoreBondAmount(moreBondAmount); |
| | | contractMoneyInfoVo.setLessBondAmount(lessBondAmount); |
| | | return Result.ok(contractMoneyInfoVo); |
| | | } |
| | | |
| | |
| | | List<ContractHoldOrderEntity> list = contractHoldOrderDao.selectHoldOrderListByMemberId(member.getId()); |
| | | List<ContractEntrustOrderEntity> entrustList = contractEntrustOrderDao.selectEntrustOrderListByMemberId(member.getId()); |
| | | |
| | | if (CollUtil.isNotEmpty(list) || CollUtil.isNotEmpty(entrustList)) { |
| | | return Result.fail("存在持仓/委托, 无法更改"); |
| | | // if (CollUtil.isNotEmpty(list) || CollUtil.isNotEmpty(entrustList)) { |
| | | // return Result.fail("存在持仓/委托, 无法更改"); |
| | | // } |
| | | |
| | | if(CollUtil.isNotEmpty(list)) { |
| | | for(ContractHoldOrderEntity contractHoldOrderEntity : list) { |
| | | String symbol = contractHoldOrderEntity.getSymbol(); |
| | | if(StrUtil.isEmpty(symbol)) { |
| | | return Result.fail("存在持仓/委托, 无法更改"); |
| | | } |
| | | return Result.fail("币种"+symbol+"存在持仓/委托, 无法更改"); |
| | | } |
| | | } |
| | | if(CollUtil.isNotEmpty(entrustList)) { |
| | | for(ContractEntrustOrderEntity contractEntrustOrderEntity : entrustList) { |
| | | String symbol = contractEntrustOrderEntity.getSymbol(); |
| | | if(StrUtil.isEmpty(symbol)) { |
| | | return Result.fail("存在持仓/委托, 无法更改"); |
| | | } |
| | | return Result.fail("币种"+symbol+"存在持仓/委托, 无法更改"); |
| | | } |
| | | } |
| | | |
| | | /** |