From 7cfeee9cf8405c06261fd6f9345f2c9bfaee85a2 Mon Sep 17 00:00:00 2001
From: zainali5120 <512061637@qq.com>
Date: Sun, 31 May 2020 23:03:33 +0800
Subject: [PATCH] 订单止盈止损类提交
---
src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 132 ++++++++++++++++++--------------------------
src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java | 2
2 files changed, 56 insertions(+), 78 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
index e24d711..45eaabf 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
@@ -1,6 +1,8 @@
package com.xcong.excoin.modules.contract.service.impl;
import com.alibaba.fastjson.JSONObject;
+import com.xcong.excoin.modules.coin.dao.MemberAccountFlowEntityDao;
+import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity;
import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
@@ -8,6 +10,7 @@
import com.xcong.excoin.modules.contract.service.ContractEntrustOrderService;
import com.xcong.excoin.modules.contract.service.ContractHoldOrderService;
import com.xcong.excoin.modules.contract.service.ContractOrderService;
+import com.xcong.excoin.modules.member.dao.AgentReturnDao;
import com.xcong.excoin.modules.member.entity.AgentReturnEntity;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
@@ -20,8 +23,6 @@
import com.xcong.excoin.utils.CacheSettingUtils;
import com.xcong.excoin.utils.CalculateUtil;
import org.apache.commons.collections.CollectionUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -55,6 +56,12 @@
@Resource
MemberService memberService;
+
+ @Resource
+ private AgentReturnDao agentReturnDao;
+
+ @Resource
+ private MemberAccountFlowEntityDao memberAccountFlowEntityDao;
@@ -185,21 +192,11 @@
BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId());
- // 流水记录 TODO 531
-// MemberAccountFlowRecord record = new MemberAccountFlowRecord();
-// record.setCreateTime(new Date());
-// record.setDirectionSource("止盈平仓");
-// record.setRemark("止盈平仓");
-// record.setMemberBalance(wallet.getAvailableBalance());
-// record.setMemberid(order.getMemberId());
-// record.setSymbolName(order.getSymbol());
-// record.setMemberName(wallet.getMemberName());
-// record.setMemberPhone(order.getMemberPhone());
-// record.setPrice(profitLossPrice + order.getPrePrice());
-// memberService.addFlowRecord(record);
-//
-// //返佣 TODO 531
-// calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2);
+ // 流水记录 TODO 531e
+ insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
+
+ //返佣
+ calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2);
}
}
}
@@ -282,21 +279,11 @@
BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId());
-// // 流水记录 TODO 531
-// MemberAccountFlowRecord record = new MemberAccountFlowRecord();
-// record.setCreateTime(new Date());
-// record.setDirectionSource("止盈平仓");
-// record.setRemark("止盈平仓");
-// record.setMemberBalance(wallet.getAvailableBalance());
-// record.setMemberid(order.getMemberId());
-// record.setSymbolName(order.getSymbol());
-// record.setMemberName(wallet.getMemberName());
-// record.setMemberPhone(order.getMemberPhone());
-// record.setPrice(profitLossPrice + order.getPrePrice());
-// memberService.addFlowRecord(record);
-//
-// //返佣 TODO 531
-// calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2);
+
+ insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
+
+ //返佣
+ calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2);
}
}
}
@@ -381,21 +368,10 @@
BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId());
- // 流水记录 TODO 531
-// MemberAccountFlowRecord record = new MemberAccountFlowRecord();
-// record.setCreateTime(new Date());
-// record.setDirectionSource("开多止损平仓");
-// record.setRemark("开多止损平仓");
-// record.setMemberBalance(wallet.getAvailableBalance());
-// record.setMemberid(order.getMemberId());
-// record.setSymbolName(order.getSymbol());
-// record.setMemberName(wallet.getMemberName());
-// record.setMemberPhone(order.getMemberPhone());
-// record.setPrice(profitLossPrice + order.getPrePrice());
-// memberService.addFlowRecord(record);
-//
-// //返佣 TODO
-// calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2);
+ insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓");
+
+ //返佣
+ calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2);
}
}
}
@@ -479,26 +455,27 @@
BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
memberWalletContractService.increaseWalletContractBalanceById(totalBalance,totalReturn,null,wallet.getId());
- // 流水记录 TODO 531
-// MemberAccountFlowRecord record = new MemberAccountFlowRecord();
-// record.setCreateTime(new Date());
-// record.setDirectionSource("开空止损平仓");
-// record.setRemark("开空止损平仓");
-// record.setMemberBalance(wallet.getAvailableBalance());
-// record.setMemberid(order.getMemberId());
-// record.setSymbolName(order.getSymbol());
-// record.setMemberName(wallet.getMemberName());
-// record.setMemberPhone(order.getMemberPhone());
-// record.setPrice(profitLossPrice + order.getPrePrice());
-// memberService.addFlowRecord(record);
-//
-// //返佣 TODO
-// calYj(order.getMemberId(), new BigDecimal(order.getClosingPrice()), order, 2);
-//
+ insertAccountFlow(order, wallet, profitLossPrice, "开空止损平仓");
+
+ //返佣
+ calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2);
+
}
}
}
}
+ }
+
+ private void insertAccountFlow(ContractHoldOrderEntity order, MemberWalletContractEntity wallet, BigDecimal profitLossPrice, String source) {
+ MemberAccountFlowEntity record = new MemberAccountFlowEntity();
+ record.setCreateTime(new Date());
+ record.setSource(source);
+ record.setRemark(source);
+ record.setBalance(wallet.getAvailableBalance());
+ record.setMemberId(order.getMemberId());
+ record.setSymbol(order.getSymbol());
+ record.setPrice(profitLossPrice.add(order.getPrePaymentAmount()));
+ memberAccountFlowEntityDao.insert(record);
}
@@ -585,7 +562,7 @@
memberWalletContractService.increaseWalletContractBalanceById(null,totalBalance,null,wallet.getId());
// TODO 531 待写
- //calYj(memId, new BigDecimal(coinsCoinsOrder.getClosingPrice()), coinsCoinsOrder, 1);
+ calYj(memId, contractOrderEntity.getClosingFeeAmount(), contractOrderEntity, 1);
}
}
}
@@ -666,19 +643,17 @@
BigDecimal totalPrice = coinsOrder.getPrePaymentAmount().negate();
//Double totalPrice = - coinsOrder.getPrePrice();
memberWalletContractService.increaseWalletContractBalanceById(null,totalPrice,null,usdt.getId());
-
// 流水记录 TODO
-// MemberAccountFlowRecord record = new MemberAccountFlowRecord();
-// record.setCreateTime(new Date());
-// record.setDirectionSource("系统自动平仓");
-// record.setRemark("系统自动平仓");
-// record.setMemberBalance(coinsOrder.getPrePrice());
-// record.setMemberid(memId);
-// record.setSymbolName(null);
-// record.setMemberName(null);
-// record.setMemberPhone(null);
-// record.setPrice(coinsOrder.getPrePrice());
-// memberService.addFlowRecord(record);
+ MemberAccountFlowEntity record = new MemberAccountFlowEntity();
+ record.setCreateTime(new Date());
+ record.setSource("系统自动平仓");
+ record.setRemark("系统自动平仓");
+ record.setBalance(usdt.getAvailableBalance());
+ record.setMemberId(memId);
+ record.setSymbol(coinsOrder.getSymbol());
+ record.setPrice(coinsOrder.getPrePaymentAmount());
+ memberAccountFlowEntityDao.insert(record);
+
}
}
@@ -743,10 +718,11 @@
agent.setOrderId(order.getId());
agent.setOrderNo(order.getOrderNo());
agent.setRefererId(agentMember.getId());
- agent.setOrderType(order.getClosingType());
+ agent.setOrderType(order.getOrderType());
agent.setReturnSymbol(order.getSymbol());
agent.setIsReturn(0);
agent.setReturnAmount(entry.getValue());
+ agent.setClosingType(order.getClosingType());
if (type == 1) {//开仓
agent.setOpeningFeeAmount(order.getOpeningFeeAmount());
} else if (type == 2) {//平仓
@@ -755,7 +731,7 @@
agent.setHoldingFeeAmount(order.getHoldAmount());
}
agent.setInviteId(entry.getKey());
- //agentReturnMapper.insert(agent);
+ agentReturnDao.insert(agent);
}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java
index d99f411..a3f6b84 100644
--- a/src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/member/entity/AgentReturnEntity.java
@@ -44,4 +44,6 @@
private int isReturn;
private String returnSymbol;
+
+ private int closingType;
}
--
Gitblit v1.9.1