xiaoyong931011
2021-03-30 c428522a1d47199b30acf4522a33c88f54180fdd
20210329  返利记录的修改
7 files modified
116 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java 35 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/common/NoticeConstant.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/dao/FollowTraderProfitDetailDao.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/service/impl/FollowOrderOperationServiceImpl.java 46 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/contract/ContractOrderDao.xml 9 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/documentary/FollowTraderProfitDetailDao.xml 13 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
@@ -35,4 +35,6 @@
    public BigDecimal getBurstUsdtByMemberId(@Param("memberId") Long memberId);
    public List<ContractOrderEntity> selectFollowOrderListByMemberId(@Param("tradeMemberId")Long tradeMemberId);
    public String selectOrderNoByOrderIds(@Param("orderId")Long orderId);
}
src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
@@ -195,23 +195,24 @@
                        memberWalletContractDao.increaseWalletContractBalanceById(returnMoney, returnMoney, null, traderWallet.getId());
                        insertReturnProfitDetail(traderInfoEntity.getMemberId(), memberEntity.getId(), returnMoney, holdOrderEntity.getOrderNo());
                        //增加返佣提醒
                        String orderNo = holdOrderEntity.getOrderNo();
                        LogRecordUtils.insertFollowerNotice(traderInfoEntity.getMemberId(),
                                NoticeConstant.RETURN_MONEY_TITLE,
                                StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT,
                                        orderNo,
                                        holdOrderEntity.getSymbol(),
                                        returnMoney.setScale(2, BigDecimal.ROUND_HALF_UP).toString()));
                        //带单返利的记录要在资产页面的其他记录
                        LogRecordUtils.insertMemberAccountMoneyChange(
                                traderInfoEntity.getMemberId(),
                                StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT_MAMC,
                                        orderNo,
                                        holdOrderEntity.getSymbol()),
                                returnMoney.setScale(2, BigDecimal.ROUND_HALF_UP),
                                MemberWalletCoinEnum.WALLETCOINCODE.getValue(),
                                MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER,
                                MemberAccountMoneyChange.TYPE_WALLET_AGENT);
//                        String orderNo = holdOrderEntity.getOrderNo();
//                        LogRecordUtils.insertFollowerNotice(traderInfoEntity.getMemberId(),
//                                NoticeConstant.RETURN_MONEY_TITLE,
//                                StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT,
//                                        orderNo,
//                                        holdOrderEntity.getSymbol(),
//                                        returnMoney.setScale(2, BigDecimal.ROUND_HALF_UP).toString()));
//                        //带单返利的记录要在资产页面的其他记录
//                        LogRecordUtils.insertMemberAccountMoneyChange(
//                                traderInfoEntity.getMemberId(),
//                                StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT_MAMC,
//                                        orderNo,
//                                        holdOrderEntity.getSymbol(),
//                                        returnMoney.setScale(2, BigDecimal.ROUND_HALF_UP).toString()),
//                                returnMoney.setScale(2, BigDecimal.ROUND_HALF_UP),
//                                MemberWalletCoinEnum.WALLETCOINCODE.getValue(),
//                                MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER,
//                                MemberAccountMoneyChange.TYPE_WALLET_AGENT);
                    }
                }
            }
src/main/java/com/xcong/excoin/modules/documentary/common/NoticeConstant.java
@@ -30,8 +30,8 @@
    public static final String BOMB_ORDER_CONTENT = "因市场剧烈波动,您的{}合约已被强制平仓,交易员:{}";
    public static final String RETURN_MONEY_TITLE = "跟单-平仓返佣";
    public static final String RETURN_MONEY_CONTENT = "平仓成功,收到的合约单号为{},币种为{}的返佣金额:{}";
    public static final String RETURN_MONEY_TITLE = "跟单-平仓返利";
    public static final String RETURN_MONEY_CONTENT = "平仓成功,收到的合约{},币种{}的返利金额:{}";
    public static final String RETURN_MONEY_CONTENT_MAMC = "合约{},币种{}的返利";
}
src/main/java/com/xcong/excoin/modules/documentary/dao/FollowTraderProfitDetailDao.java
@@ -1,8 +1,15 @@
package com.xcong.excoin.modules.documentary.dao;
import java.math.BigDecimal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xcong.excoin.modules.documentary.entity.FollowTraderProfitDetailEntity;
public interface FollowTraderProfitDetailDao extends BaseMapper<FollowTraderProfitDetailEntity> {
    BigDecimal selectFollowHoldOrderByFollowOrderNo(@Param("orderNos")List<String> orderNos);
}
src/main/java/com/xcong/excoin/modules/documentary/service/impl/FollowOrderOperationServiceImpl.java
@@ -7,9 +7,11 @@
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
import com.xcong.excoin.common.enumerates.RabbitPriceTypeEnum;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.common.system.service.CommonService;
import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
import com.xcong.excoin.modules.contract.dao.ContractOrderDao;
import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
@@ -18,10 +20,7 @@
import com.xcong.excoin.modules.contract.mapper.ContractHoldOrderEntityMapper;
import com.xcong.excoin.modules.contract.service.RabbitOrderService;
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.dao.*;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerOrderRelationEntity;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerProfitEntity;
import com.xcong.excoin.modules.documentary.entity.FollowFollowerSettingEntity;
@@ -88,6 +87,8 @@
    @Autowired
    private FollowProducer followProducer;
    @Autowired
    private FollowTraderProfitDetailDao followTraderProfitDetailDao;
    @Override
@@ -263,11 +264,48 @@
    public void closingFollowOrders(String orderNo) {
        List<FollowFollowerOrderRelationEntity> orderRelations = followFollowerOrderRelationDao.selectFollowHoldOrderByTradeOrderNo(orderNo);
        if (CollUtil.isNotEmpty(orderRelations)) {
            List<Long> orderIds = new ArrayList<>();
            for (FollowFollowerOrderRelationEntity orderRelation : orderRelations) {
                List<Long> ids= new ArrayList<>();
                ids.add(orderRelation.getOrderId());
                orderIds.add(orderRelation.getOrderId());
                rabbitOrderService.cancelHoldOrder(ids);
            }
            if(CollUtil.isNotEmpty(orderIds)){
                //获取对应的平仓记录单号
                List<String> orderNosList = new ArrayList<>();
                for(Long orderId : orderIds) {
                    String orderNos = contractOrderDao.selectOrderNoByOrderIds(orderId);
                    ContractOrderEntity contractOrderEntity = contractOrderDao.selectById(orderId);
                    orderNosList.add(orderNos);
                }
                //获取总返佣
                BigDecimal totalAmount = followTraderProfitDetailDao.selectFollowHoldOrderByFollowOrderNo(orderNosList);
                totalAmount = (totalAmount == null?BigDecimal.ZERO:totalAmount.setScale(2, BigDecimal.ROUND_DOWN));
                if(totalAmount.compareTo(BigDecimal.ZERO) > 0){
                    //增加返佣提醒
                    String symbol = contractOrderDao.selectById(orderIds.get(0)).getSymbol();
                    String orderNoTrader = orderRelations.get(0).getTradeOrderNo();
                    Long traderMemberId = orderRelations.get(0).getTradeMemberId();
                    LogRecordUtils.insertFollowerNotice(traderMemberId,
                            NoticeConstant.RETURN_MONEY_TITLE,
                            StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT,
                                    orderNoTrader,
                                    symbol,
                                    totalAmount));
                    //带单返利的记录要在资产页面的其他记录
                    LogRecordUtils.insertMemberAccountMoneyChange(
                            traderMemberId,
                            StrUtil.format(NoticeConstant.RETURN_MONEY_CONTENT_MAMC,
                                    orderNoTrader,
                                    symbol),
                            totalAmount,
                            MemberWalletCoinEnum.WALLETCOINCODE.getValue(),
                            MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER,
                            MemberAccountMoneyChange.TYPE_WALLET_AGENT);
                }
            }
        }
    }
}
src/main/resources/mapper/contract/ContractOrderDao.xml
@@ -2,6 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xcong.excoin.modules.contract.dao.ContractOrderDao">
    <select id="selectOrderNoByOrderIds" resultType="java.lang.String">
        SELECT
            order_no
        FROM
            contract_order
        WHERE
              id = #{orderId}
    </select>
    <select id="selectFollowOrderListByMemberId" resultType="com.xcong.excoin.modules.contract.entity.ContractOrderEntity">
        SELECT
            *
src/main/resources/mapper/documentary/FollowTraderProfitDetailDao.xml
@@ -1,6 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xcong.excoin.modules.documentary.dao.FollowTraderProfitDetailDao">
    <select id="selectFollowHoldOrderByFollowOrderNo" resultType="java.math.BigDecimal">
        SELECT
        sum(amount)
        FROM
        follow_trader_profit_detail
        WHERE
        order_no in
        <foreach collection="orderNos" item="item" index="" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
    
</mapper>