From 9f6842c70812fa3e2ccf96ccb73b7aa3a2518f34 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 26 Mar 2021 16:11:01 +0800
Subject: [PATCH] 20210326 增加返佣提醒
---
src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 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 b61cfba..06164aa 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,7 +1,10 @@
package com.xcong.excoin.modules.contract.service.impl;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xcong.excoin.common.contants.AppContants;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
import com.xcong.excoin.modules.coin.dao.MemberAccountFlowEntityDao;
@@ -16,6 +19,14 @@
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.documentary.common.NoticeConstant;
+import com.xcong.excoin.modules.documentary.dao.FollowFollowerOrderRelationDao;
+import com.xcong.excoin.modules.documentary.dao.FollowFollowerProfitDao;
+import com.xcong.excoin.modules.documentary.dao.FollowFollowerSettingDao;
+import com.xcong.excoin.modules.documentary.dao.FollowTraderInfoDao;
+import com.xcong.excoin.modules.documentary.entity.FollowFollowerOrderRelationEntity;
+import com.xcong.excoin.modules.documentary.entity.FollowFollowerSettingEntity;
+import com.xcong.excoin.modules.documentary.entity.FollowTraderInfoEntity;
import com.xcong.excoin.modules.documentary.service.FollowOrderOperationService;
import com.xcong.excoin.modules.member.dao.AgentReturnDao;
import com.xcong.excoin.modules.member.dao.MemberSettingDao;
@@ -58,6 +69,16 @@
@Resource
MemberWalletContractService memberWalletContractService;
+
+ @Resource
+ FollowFollowerProfitDao followFollowerProfitDao;
+
+ @Resource
+ FollowFollowerSettingDao followFollowerSettingDao;
+ @Resource
+ FollowFollowerOrderRelationDao followFollowerOrderRelationDao;
+ @Resource
+ FollowTraderInfoDao followTraderInfoDao;
@Resource
CacheSettingUtils cacheSettingUtils;
@@ -889,6 +910,22 @@
if (ContractOrderEntity.CONTRACTTYPE_DOCUMENTARY == coinsOrder.getContractType() && MemberEntity.IS_TRADER_Y.equals(memberEntity.getIsTrader())) {
followOrderOperationService.closingFollowOrders(coinsOrder.getOrderNo());
}
+ // 如果不是交易员,
+ if (ContractOrderEntity.CONTRACTTYPE_DOCUMENTARY == coinsOrder.getContractType() && !MemberEntity.IS_TRADER_Y.equals(memberEntity.getIsTrader())) {
+ //更新他的个人跟随者收益记录
+ QueryWrapper<FollowFollowerSettingEntity> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("member_id",coinsOrder.getMemberId());
+ FollowFollowerSettingEntity followFollowerSettingEntity = followFollowerSettingDao.selectOne(queryWrapper);
+ if(ObjectUtil.isNotEmpty(followFollowerSettingEntity)){
+ Long traderMemberId = followFollowerSettingEntity.getTraderMemberId();
+ followFollowerProfitDao.updateFollowerProfitByTradeMemberId(coinsOrder.getBondAmount().negate(), coinsOrder.getBondAmount().negate(), traderMemberId, memberEntity.getId());
+ }
+ FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectById(followFollowerSettingEntity.getTraderId());
+ //更新跟随者-订单关联表
+ updateFollowOrderRelation(coinsOrder.getId(), contractOrderEntity.getId());
+ //增加爆仓消息提醒
+ LogRecordUtils.insertFollowerNotice(memberEntity.getId(), NoticeConstant.BOMB_ORDER_TITLE, StrUtil.format(NoticeConstant.BOMB_ORDER_CONTENT, contractOrderEntity.getSymbol(),followTraderInfoEntity.getNickname()));
+ }
} else {
MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memId, "USDT");
@@ -920,6 +957,21 @@
}
}
+ /**
+ * 更新跟单订单关系
+ *
+ * @param oldOrderId 当前持仓ID
+ * @param newOrderId 历史订单ID
+ */
+ public void updateFollowOrderRelation(Long oldOrderId, Long newOrderId) {
+ FollowFollowerOrderRelationEntity orderRelationEntity = followFollowerOrderRelationDao.selectNowOneByorderId(oldOrderId);
+ if (orderRelationEntity != null) {
+ orderRelationEntity.setOrderId(newOrderId);
+ orderRelationEntity.setOrderType(FollowFollowerOrderRelationEntity.ORDER_TYPE_HISTORY);
+ followFollowerOrderRelationDao.updateById(orderRelationEntity);
+ }
+ }
+
public void calYj(Long mid, BigDecimal money, ContractOrderEntity order, int type) {
PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
if (money != null) {
--
Gitblit v1.9.1