From 71f7a93df3ec759ee33701fcc7e9d57f553d6cba Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 04 Mar 2021 17:46:43 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java | 81 ++++++++++++++++++++++++++++++++++------
1 files changed, 68 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java b/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
index 92712d1..2f93ebe 100644
--- a/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java
@@ -16,6 +16,7 @@
import com.xcong.excoin.utils.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
@@ -39,6 +40,7 @@
import com.xcong.excoin.modules.documentary.dao.FollowTraderLabelDao;
import com.xcong.excoin.modules.documentary.dao.FollowTraderProfitDetailDao;
import com.xcong.excoin.modules.documentary.dao.FollowTraderProfitInfoDao;
+import com.xcong.excoin.modules.documentary.dto.BeTraderDto;
import com.xcong.excoin.modules.documentary.dto.CancelDocumentaryOrderSetDto;
import com.xcong.excoin.modules.documentary.dto.DocumentaryOrderSetDto;
import com.xcong.excoin.modules.documentary.dto.FollowFollowerNoticeDto;
@@ -285,7 +287,43 @@
}else {
followInfoVo.setNickname(phone);
}
-
+
+ List<ContractHoldOrderEntity> myFollowOrder = followFollowerProfitDao.getFollowOrderNowRecords(memberId);
+
+ BigDecimal totalBondAmount = BigDecimal.ZERO;
+ BigDecimal profitOrLess = BigDecimal.ZERO;
+ if (CollUtil.isNotEmpty(myFollowOrder)) {
+ for(ContractHoldOrderEntity contractHoldOrderEntity : myFollowOrder) {
+ BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(contractHoldOrderEntity.getSymbol())));
+ BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(contractHoldOrderEntity.getSymbol());
+
+ // 盈亏
+ BigDecimal rewardRatio = BigDecimal.ZERO;
+ // 开多
+ if (contractHoldOrderEntity.OPENING_TYPE_MORE == contractHoldOrderEntity.getOpeningType()) {
+ // (最新价-开仓价)*规格*张数
+ rewardRatio = newPrice.subtract(contractHoldOrderEntity.getOpeningPrice()).multiply(lotNumber).multiply(new BigDecimal(contractHoldOrderEntity.getSymbolCnt()));
+ // 开空
+ } else {
+ // (开仓价-最新价)*规格*张数
+ rewardRatio = contractHoldOrderEntity.getOpeningPrice().subtract(newPrice).multiply(lotNumber).multiply(new BigDecimal(contractHoldOrderEntity.getSymbolCnt()));
+ }
+
+ if (member.getIsProfit() == MemberEntity.IS_PROFIT_Y) {
+ PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
+ if (rewardRatio.compareTo(BigDecimal.ZERO) > -1) {
+ rewardRatio = rewardRatio.multiply(BigDecimal.ONE.subtract(tradeSettingEntity.getProfitParam()));
+ }
+ }
+
+ profitOrLess = profitOrLess.add(rewardRatio).setScale(2, BigDecimal.ROUND_DOWN);
+ totalBondAmount = totalBondAmount.add(contractHoldOrderEntity.getBondAmount());
+ }
+ }
+
+ followInfoVo.setTotalAmount(totalBondAmount);
+ followInfoVo.setTotalProfitOrLess(profitOrLess);
+
BigDecimal totalPrincipals = BigDecimal.ZERO;
BigDecimal totalProfits = BigDecimal.ZERO;
Map<String, Object> columnMap = new HashMap<>();
@@ -594,7 +632,7 @@
public Result getDocumentaryOrderSetInfo(String tradeId) {
//获取用户ID
Long memberId = LoginUserUtils.getAppLoginUser().getId();
- log.info("跟单---跟单设置--进入编辑---"+memberId+"参数"+tradeId);
+ log.info("跟单---点击跟单或者编辑---"+memberId+"参数"+tradeId);
DocumentaryOrderSetInfoVo documentaryOrderSetInfoVo = new DocumentaryOrderSetInfoVo();
long parseLong = Long.parseLong(tradeId);
@@ -605,7 +643,7 @@
if(CollUtil.isNotEmpty(followFollowerSettingEntityAllows)) {
for(FollowFollowerSettingEntity followFollowerSettingEntityAllow : followFollowerSettingEntityAllows) {
Long tradeIdAllow = followFollowerSettingEntityAllow.getTraderId();
- if(!tradeIdAllow.toString().equals(tradeId)) {
+ if(parseLong != tradeIdAllow) {
return Result.fail(MessageSourceUtils.getString("documentary_service_0015"));
}
}
@@ -640,7 +678,7 @@
if(maxFollowCnt > 0){
documentaryOrderSetInfoVo.setMaxFollowCnt(maxFollowCnt.toString());
}
- documentaryOrderSetInfoVo.setMaxFollowCnt(null);
+ documentaryOrderSetInfoVo.setMaxFollowCnt("");
log.info(memberId + "-最大持仓张数-"+maxFollowCnt.toString());
return Result.ok(documentaryOrderSetInfoVo);
}
@@ -718,7 +756,15 @@
@Override
@Transactional
- public Result beTrader() {
+ public Result beTrader(@Valid BeTraderDto beTraderDto) {
+ //头像
+ String avatar = beTraderDto.getAvatar();
+ //昵称
+ String nickname = beTraderDto.getNickname();
+ //宣言
+ String declaration = beTraderDto.getDeclaration();
+ //标签
+ String labels = beTraderDto.getLabels();
//获取用户ID
Long memberId = LoginUserUtils.getAppLoginUser().getId();
MemberEntity memberEntity = memberDao.selectById(memberId);
@@ -756,15 +802,24 @@
followTraderInfoEntity.setMemberId(memberId);
followTraderInfoEntity.setProfitRatio(BigDecimal.valueOf(0.1));
// followTraderInfoEntity.setAvatar(FollowTraderInfoEntity.AVATAR_DEFAULT);
- String phone = memberEntity.getPhone();
- String email = memberEntity.getEmail();
- if(StrUtil.isNotEmpty(phone)) {
- followTraderInfoEntity.setNickname(phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
- }else {
- followTraderInfoEntity.setNickname(email.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)","$1****$3$4"));
+// String phone = memberEntity.getPhone();
+// String email = memberEntity.getEmail();
+// if(StrUtil.isNotEmpty(phone)) {
+// followTraderInfoEntity.setNickname(phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
+// }else {
+// followTraderInfoEntity.setNickname(email.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)","$1****$3$4"));
+// }
+ if(StrUtil.isNotEmpty(avatar)) {
+ followTraderInfoEntity.setAvatar(avatar);
}
- followTraderInfoEntity.setNicknameState(FollowTraderInfoEntity.STATE_N);
- followTraderInfoEntity.setDeclaration(FollowTraderInfoEntity.DECLARATION_DEFAULT);
+ followTraderInfoEntity.setNickname(nickname);
+ followTraderInfoEntity.setNicknameState(FollowTraderInfoEntity.STATE_Y);
+ if(StrUtil.isEmpty(declaration)) {
+ followTraderInfoEntity.setDeclaration(FollowTraderInfoEntity.DECLARATION_DEFAULT);
+ }else {
+ followTraderInfoEntity.setDeclaration(declaration);
+ }
+ followTraderInfoEntity.setLabels(labels);
followTraderInfoEntity.setIsAll(FollowTraderInfoEntity.IS_ALL_N);
followTraderInfoEntity.setProfitRatio(BigDecimal.ZERO);
followTraderInfoEntity.setVerifyStatus(FollowTraderInfoEntity.VERIFYSTATUS_ING);
--
Gitblit v1.9.1