From a00d810984fe187d24e442d5f557bcc271cfa3ce Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 28 Jan 2021 11:25:49 +0800
Subject: [PATCH] Merge branch 'whole_new' of https://gitee.com/chonggaoxiao/new_excoin.git into whole_new
---
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
index 35217b3..d80b492 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.huobi.client.model.Candlestick;
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.contants.AppContants;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
@@ -24,8 +25,10 @@
import com.xcong.excoin.modules.contract.parameter.vo.*;
import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
import com.xcong.excoin.modules.documentary.dao.FollowFollowerOrderRelationDao;
+import com.xcong.excoin.modules.documentary.dao.FollowFollowerProfitDao;
import com.xcong.excoin.modules.documentary.dao.FollowTraderInfoDao;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerOrderRelationEntity;
+import com.xcong.excoin.modules.documentary.entity.FollowFollowerProfitEntity;
import com.xcong.excoin.modules.documentary.entity.FollowTraderInfoEntity;
import com.xcong.excoin.modules.member.dao.MemberDao;
import com.xcong.excoin.modules.member.dao.MemberLevelRateDao;
@@ -86,8 +89,12 @@
@Resource
private MemberDao memberDao;
+
@Resource
private MemberSettingDao memberSettingDao;
+
+ @Resource
+ private FollowFollowerProfitDao followFollowerProfitDao;
@Resource
private FollowTraderInfoDao followTraderInfoDao;
@@ -185,6 +192,7 @@
wholeHoldOrder.setSymbolCntSale(wholeHoldOrder.getSymbolCntSale() + submitOrderDto.getSymbolCnt());
wholeHoldOrder.setPrePaymentAmount(prePaymentAmount.add(wholeHoldOrder.getPrePaymentAmount()));
wholeHoldOrder.setOperateNo(wholeHoldOrder.getOperateNo());
+ wholeHoldOrder.setHoldBond(CalculateUtil.calMemberHoldBond(wholeHoldOrder));
int i = contractHoldOrderDao.updateById(wholeHoldOrder);
if (i > 0) {
memberWalletContractDao.increaseWalletContractBalanceById(prePaymentAmount.negate(), openFeePrice.negate(), null, walletContract.getId());
@@ -231,6 +239,8 @@
ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity);
contractOrderEntity.setOpeningTime(new Date());
+
+ holdOrderEntity.setHoldBond(CalculateUtil.calMemberHoldBond(holdOrderEntity));
contractHoldOrderDao.insert(holdOrderEntity);
int i = contractOrderDao.insert(contractOrderEntity);
@@ -474,12 +484,13 @@
// canAddMaxBond = BigDecimal.ZERO;
// }
BigDecimal canReduceMaxBond = holdOrderEntity.getBondAmount().subtract(holdOrderEntity.getPrePaymentAmount());
- if (canReduceMaxBond.compareTo(BigDecimal.ZERO) < 0) {
- canReduceMaxBond = BigDecimal.ZERO;
- }
if (rewardRatio.compareTo(BigDecimal.ZERO) < 0) {
canReduceMaxBond = canReduceMaxBond.add(rewardRatio);
+ }
+
+ if (canReduceMaxBond.compareTo(BigDecimal.ZERO) < 0) {
+ canReduceMaxBond = BigDecimal.ZERO;
}
holdOrderListVo.setCanReduceMaxBond(canReduceMaxBond);
@@ -826,7 +837,11 @@
if (equity.compareTo(BigDecimal.ZERO) <= 0) {
equity = BigDecimal.ZERO;
}
-
+
+ // 获取当日k线的开盘价
+ Candlestick symbolObject = (Candlestick) redisUtils.get(symbol);
+ BigDecimal openPrice = symbolObject.getOpen();
+ BigDecimal upOrDown = newPriceSymbol.subtract(openPrice).divide(openPrice, 8, BigDecimal.ROUND_HALF_UP);
contractMoneyInfoVo.setBeUsedBondAmount(beUsedBondAmount);
contractMoneyInfoVo.setFrozenBondAmount(frozenBondAmount);
contractMoneyInfoVo.setEquity(equity);
@@ -834,6 +849,7 @@
contractMoneyInfoVo.setFeeRatio(tradeSetting.getFeeRatio());
contractMoneyInfoVo.setLeverAgeRatio(tradeSetting.getLeverageRatio());
contractMoneyInfoVo.setNewPrice(newPriceSymbol);
+ contractMoneyInfoVo.setUpOrDown(upOrDown);
contractMoneyInfoVo.setSymbolSku(cacheSettingUtils.getSymbolSku(symbol));
contractMoneyInfoVo.setLeverRate(rateEntity.getLevelRateUp());
return Result.ok(contractMoneyInfoVo);
@@ -969,6 +985,15 @@
if (CollUtil.isNotEmpty(list) || CollUtil.isNotEmpty(entrustList)) {
return Result.fail("存在持仓/委托, 无法更改");
}
+
+ /**
+ * 验证用户是否存在跟随交易员
+ * 是:不允许切换成全仓模式
+ */
+ List<FollowFollowerProfitEntity> followFollowerProfitEntitys = followFollowerProfitDao.selectByMemberIdandIsFollow(member.getId(),FollowFollowerProfitEntity.IS_FOLLOW_Y);
+ if(CollUtil.isNotEmpty(followFollowerProfitEntitys)) {
+ return Result.fail(MessageSourceUtils.getString("documentary_service_0018"));
+ }
Integer positionType = member.getContractPositionType() == ContractEntrustOrderEntity.POSITION_TYPE_ADD ? ContractEntrustOrderEntity.POSITION_TYPE_ALL : ContractEntrustOrderEntity.POSITION_TYPE_ADD;
MemberEntity updateEntity = new MemberEntity();
--
Gitblit v1.9.1