From 85432ec0106fe27c2b2dbad5fdf0ea822e038859 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 03 Mar 2021 11:20:32 +0800
Subject: [PATCH] 20210303   交易员首页推荐

---
 src/main/java/com/xcong/excoin/modules/documentary/dto/FollowTraderProfitInfoDto.java       |   25 ++++++++
 src/main/resources/mapper/documentary/FollowTraderProfitInfoDao.xml                         |   12 +++
 src/main/java/com/xcong/excoin/modules/documentary/controller/DocumentaryController.java    |    3 
 src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderInfoEntity.java       |    6 ++
 src/main/java/com/xcong/excoin/modules/documentary/service/DocumentaryService.java          |    3 
 src/main/java/com/xcong/excoin/modules/documentary/service/impl/DocumentaryServiceImpl.java |  108 +++++++++++++++++++-----------------
 src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderProfitInfoEntity.java |    4 +
 7 files changed, 106 insertions(+), 55 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/documentary/controller/DocumentaryController.java b/src/main/java/com/xcong/excoin/modules/documentary/controller/DocumentaryController.java
index 2d734e4..d8c3fe1 100644
--- a/src/main/java/com/xcong/excoin/modules/documentary/controller/DocumentaryController.java
+++ b/src/main/java/com/xcong/excoin/modules/documentary/controller/DocumentaryController.java
@@ -16,6 +16,7 @@
 import com.xcong.excoin.modules.documentary.dto.DocumentaryOrderSetDto;
 import com.xcong.excoin.modules.documentary.dto.FollowFollowerNoticeDto;
 import com.xcong.excoin.modules.documentary.dto.FollowRecordsDto;
+import com.xcong.excoin.modules.documentary.dto.FollowTraderProfitInfoDto;
 import com.xcong.excoin.modules.documentary.dto.HistoryOrderRecordsDto;
 import com.xcong.excoin.modules.documentary.dto.MyFollowOrderDto;
 import com.xcong.excoin.modules.documentary.dto.MyFollowTraderInfoDto;
@@ -76,7 +77,7 @@
 	@ApiOperation(value="交易员列表", notes="交易员列表")
 	@ApiResponses({@ApiResponse( code = 200, message = "success", response = FollowTraderProfitInfoVo.class)})
 	@PostMapping(value = "/getFollowTraderProfitInfo")
-	public Result  getFollowTraderProfitInfo(@RequestBody @Valid RecordsPageDto recordsPageDto) {
+	public Result  getFollowTraderProfitInfo(@RequestBody @Valid FollowTraderProfitInfoDto recordsPageDto) {
 		return documentaryService.getFollowTraderProfitInfo(recordsPageDto);
 	}
 	
diff --git a/src/main/java/com/xcong/excoin/modules/documentary/dto/FollowTraderProfitInfoDto.java b/src/main/java/com/xcong/excoin/modules/documentary/dto/FollowTraderProfitInfoDto.java
new file mode 100644
index 0000000..4790c50
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/documentary/dto/FollowTraderProfitInfoDto.java
@@ -0,0 +1,25 @@
+package com.xcong.excoin.modules.documentary.dto;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "FollowTraderProfitInfoDto", description = "参数接受类")
+public class FollowTraderProfitInfoDto {
+	@NotNull
+    @Min(1)
+    @ApiModelProperty(value = "第几页", example = "1")
+    private int pageNum;
+
+    @NotNull
+    @ApiModelProperty(value = "每页数量", example = "10")
+    private int pageSize;
+    
+    @ApiModelProperty(value = "1:首页", example = "1")
+    private int type;
+    
+}
diff --git a/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderInfoEntity.java b/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderInfoEntity.java
index 28f4d6f..92ca020 100644
--- a/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderInfoEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderInfoEntity.java
@@ -47,6 +47,12 @@
     private Integer isAll;
     public static final Integer IS_ALL_Y = 1;
     public static final Integer IS_ALL_N = 2;
+
+    /**
+     * 设置成首页
+     */
+    private Integer isSetFrist;
+    public static final Integer IS_SETFRIST_Y = 1;
     /**
      * 利润
      */
diff --git a/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderProfitInfoEntity.java b/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderProfitInfoEntity.java
index d819f7f..cadb89c 100644
--- a/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderProfitInfoEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/documentary/entity/FollowTraderProfitInfoEntity.java
@@ -2,6 +2,7 @@
 
 import java.math.BigDecimal;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.xcong.excoin.common.system.base.BaseEntity;
 
@@ -53,5 +54,8 @@
      */
     private int totalOrderCnt;
     
+    @TableField(exist = false)
+    private int type;
+    
 
 }
diff --git a/src/main/java/com/xcong/excoin/modules/documentary/service/DocumentaryService.java b/src/main/java/com/xcong/excoin/modules/documentary/service/DocumentaryService.java
index f29bdcf..4d15675 100644
--- a/src/main/java/com/xcong/excoin/modules/documentary/service/DocumentaryService.java
+++ b/src/main/java/com/xcong/excoin/modules/documentary/service/DocumentaryService.java
@@ -9,6 +9,7 @@
 import com.xcong.excoin.modules.documentary.dto.DocumentaryOrderSetDto;
 import com.xcong.excoin.modules.documentary.dto.FollowFollowerNoticeDto;
 import com.xcong.excoin.modules.documentary.dto.FollowRecordsDto;
+import com.xcong.excoin.modules.documentary.dto.FollowTraderProfitInfoDto;
 import com.xcong.excoin.modules.documentary.dto.HistoryOrderRecordsDto;
 import com.xcong.excoin.modules.documentary.dto.MyFollowOrderDto;
 import com.xcong.excoin.modules.documentary.dto.MyFollowTraderInfoDto;
@@ -23,7 +24,7 @@
 
 	public Result getMemberIsTradeInfo();
 
-	public Result getFollowTraderProfitInfo(@Valid RecordsPageDto recordsPageDto);
+	public Result getFollowTraderProfitInfo(@Valid FollowTraderProfitInfoDto recordsPageDto);
 
 	public Result getHistoryOrderRecords(@Valid HistoryOrderRecordsDto historyOrderRecordsDto);
 
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 2609225..c26d763 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
@@ -41,6 +41,7 @@
 import com.xcong.excoin.modules.documentary.dto.DocumentaryOrderSetDto;
 import com.xcong.excoin.modules.documentary.dto.FollowFollowerNoticeDto;
 import com.xcong.excoin.modules.documentary.dto.FollowRecordsDto;
+import com.xcong.excoin.modules.documentary.dto.FollowTraderProfitInfoDto;
 import com.xcong.excoin.modules.documentary.dto.HistoryOrderRecordsDto;
 import com.xcong.excoin.modules.documentary.dto.MyFollowOrderDto;
 import com.xcong.excoin.modules.documentary.dto.MyFollowTraderInfoDto;
@@ -143,10 +144,14 @@
 	}
 
 	@Override
-	public Result getFollowTraderProfitInfo(@Valid RecordsPageDto recordsPageDto) {
-        
+	public Result getFollowTraderProfitInfo(@Valid FollowTraderProfitInfoDto recordsPageDto) {
+
+		int type = recordsPageDto.getType();
         Page<FollowTraderProfitInfoVo> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
         FollowTraderProfitInfoEntity followTraderProfitInfoEntity = new FollowTraderProfitInfoEntity();
+        if(FollowTraderInfoEntity.IS_SETFRIST_Y.equals(type)) {
+        	followTraderProfitInfoEntity.setType(type);
+        }
         IPage<FollowTraderProfitInfoVo> followTraderProfitInfoList = followTraderProfitInfoDao.selectFollowTraderProfitInfoEntity(page, followTraderProfitInfoEntity);
         
         List<FollowTraderProfitInfoVo> followTraderProfitInfoVoList = followTraderProfitInfoList.getRecords();
@@ -874,58 +879,59 @@
 					TradeOrderInfoVo myFollowOrderVo = new TradeOrderInfoVo();
 					//获取交易员信息
 					Long orderId = contractHoldOrderEntity.getId();
-					myFollowOrderVo.setOrderId(orderId);
 					FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectTraderInfoByMemberId(memberId);
-					String nickname = followTraderInfoEntity.getNickname();
-					myFollowOrderVo.setNickname(nickname);
-					
-					String symbol = contractHoldOrderEntity.getSymbol();
-					myFollowOrderVo.setSymbol(symbol);
-					int orderType = contractHoldOrderEntity.getOpeningType();
-					myFollowOrderVo.setOrderType(orderType);
-					int leverRatio = contractHoldOrderEntity.getLeverRatio();
-					myFollowOrderVo.setLeverRatio(leverRatio);
-					int symbolCnt = contractHoldOrderEntity.getSymbolCnt();
-					myFollowOrderVo.setSymbolCnt(symbolCnt);
-					BigDecimal bondAmount = contractHoldOrderEntity.getBondAmount().setScale(2, BigDecimal.ROUND_DOWN);
-					myFollowOrderVo.setBondAmount(bondAmount);
-					BigDecimal openingPrice = contractHoldOrderEntity.getOpeningPrice().setScale(2, BigDecimal.ROUND_DOWN);
-					myFollowOrderVo.setOpeningPrice(openingPrice);
-					String orderNo = contractHoldOrderEntity.getOrderNo();
-					myFollowOrderVo.setOrderNo(orderNo);
-					Date openingTime = contractHoldOrderEntity.getCreateTime();
-					myFollowOrderVo.setOpeningTime(openingTime);
-					
-					// 获取最新价
-					BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(contractHoldOrderEntity.getSymbol())));
-					myFollowOrderVo.setNewPrice(newPrice);
-					
-					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()));
+					if(ObjectUtil.isNotEmpty(followTraderInfoEntity)) {
+						myFollowOrderVo.setOrderId(orderId);
+						String nickname = followTraderInfoEntity.getNickname();
+						myFollowOrderVo.setNickname(nickname);
+						String symbol = contractHoldOrderEntity.getSymbol();
+						myFollowOrderVo.setSymbol(symbol);
+						int orderType = contractHoldOrderEntity.getOpeningType();
+						myFollowOrderVo.setOrderType(orderType);
+						int leverRatio = contractHoldOrderEntity.getLeverRatio();
+						myFollowOrderVo.setLeverRatio(leverRatio);
+						int symbolCnt = contractHoldOrderEntity.getSymbolCnt();
+						myFollowOrderVo.setSymbolCnt(symbolCnt);
+						BigDecimal bondAmount = contractHoldOrderEntity.getBondAmount().setScale(2, BigDecimal.ROUND_DOWN);
+						myFollowOrderVo.setBondAmount(bondAmount);
+						BigDecimal openingPrice = contractHoldOrderEntity.getOpeningPrice().setScale(2, BigDecimal.ROUND_DOWN);
+						myFollowOrderVo.setOpeningPrice(openingPrice);
+						String orderNo = contractHoldOrderEntity.getOrderNo();
+						myFollowOrderVo.setOrderNo(orderNo);
+						Date openingTime = contractHoldOrderEntity.getCreateTime();
+						myFollowOrderVo.setOpeningTime(openingTime);
+						
+						// 获取最新价
+						BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(contractHoldOrderEntity.getSymbol())));
+						myFollowOrderVo.setNewPrice(newPrice);
+						
+						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()));
+							}
+						}
+						myFollowOrderVo.setRewardAmount(rewardRatio.setScale(2, BigDecimal.ROUND_DOWN));
+						
+						// 回报率
+						BigDecimal returnRate = rewardRatio.divide(contractHoldOrderEntity.getBondAmount().subtract(contractHoldOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN);
+						myFollowOrderVo.setRewardRatio(returnRate.setScale(4, BigDecimal.ROUND_DOWN));
+						
+						myFollowOrderVos.add(myFollowOrderVo);
 					}
-					myFollowOrderVo.setRewardAmount(rewardRatio.setScale(2, BigDecimal.ROUND_DOWN));
-					
-					// 回报率
-					BigDecimal returnRate = rewardRatio.divide(contractHoldOrderEntity.getBondAmount().subtract(contractHoldOrderEntity.getOpeningFeeAmount()), 8, BigDecimal.ROUND_DOWN);
-					myFollowOrderVo.setRewardRatio(returnRate.setScale(4, BigDecimal.ROUND_DOWN));
-					
-					myFollowOrderVos.add(myFollowOrderVo);
 				}
 			}
 		
diff --git a/src/main/resources/mapper/documentary/FollowTraderProfitInfoDao.xml b/src/main/resources/mapper/documentary/FollowTraderProfitInfoDao.xml
index eb35811..d66f75b 100644
--- a/src/main/resources/mapper/documentary/FollowTraderProfitInfoDao.xml
+++ b/src/main/resources/mapper/documentary/FollowTraderProfitInfoDao.xml
@@ -3,8 +3,16 @@
 <mapper namespace="com.xcong.excoin.modules.documentary.dao.FollowTraderProfitInfoDao">
 	
 	<select id="selectFollowTraderProfitInfoEntity" resultType="com.xcong.excoin.modules.documentary.vo.FollowTraderProfitInfoVo">
-		select * from follow_trader_profit_info f left join member m on f.member_id = m.id
-		where m.is_trader = 1
+		select * from follow_trader_profit_info f
+		    left join member m on f.member_id = m.id
+			left join follow_trader_info t on t.member_id = f.member_id
+		<where>
+			m.is_trader = 1
+			<if test="record.type != null and record.type != '' ">
+				and t.is_set_frist = #{record.type}
+			</if>
+		</where>
+
         order by f.id desc
     </select>
     

--
Gitblit v1.9.1