xiaoyong931011
2021-04-06 0a52a2c2e7c94f487259a5cba57e7dce5e675372
20210406  交易员列表查询
3 files modified
18 ■■■■■ 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/quartz/job/FollowProfitUpdateJob.java 14 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/contract/ContractOrderDao.xml 2 ●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
@@ -28,7 +28,7 @@
    BigDecimal selectFollowOrderTotalProfitByMemberId(@Param("memberId") Long memberId);
    Integer selectFollowOrderCntForWinRate(@Param("memberId") Long memberId, @Param("type") Integer type);
    BigDecimal selectFollowOrderCntForWinRate(@Param("memberId") Long memberId, @Param("type") Integer type);
    List<ContractOrderEntity> selectWholeOpenOrderByOrderNo(@Param("orderNo") String orderNo);
src/main/java/com/xcong/excoin/quartz/job/FollowProfitUpdateJob.java
@@ -93,13 +93,15 @@
                List<ContractOrderEntity> orders = contractOrderDao.selectFollowOrderListByMemberId(tradeMemberId);
                traderInfoProfit.setTotalOrderCnt(CollUtil.isNotEmpty(orders) ? orders.size() : 0);
                // 近三周胜率
                Integer winCnt = contractOrderDao.selectFollowOrderCntForWinRate(tradeMemberId, 1);
                Integer allCnt = contractOrderDao.selectFollowOrderCntForWinRate(tradeMemberId, null);
                if (winCnt != null && allCnt != null && allCnt!=0) {
                    BigDecimal winRate = BigDecimal.valueOf(winCnt).divide(BigDecimal.valueOf(allCnt), 4, BigDecimal.ROUND_DOWN);
                    traderInfoProfit.setWinRate(winRate);
                BigDecimal winCnt = contractOrderDao.selectFollowOrderCntForWinRate(tradeMemberId, 1);
                winCnt = (winCnt == null?BigDecimal.ZERO:winCnt.setScale(2, BigDecimal.ROUND_DOWN));
                BigDecimal allCnt = contractOrderDao.selectFollowOrderCntForWinRate(tradeMemberId, null);
                allCnt = (allCnt == null?BigDecimal.ZERO:allCnt.setScale(2, BigDecimal.ROUND_DOWN));
                BigDecimal winRate = BigDecimal.ZERO.setScale(2, BigDecimal.ROUND_DOWN);
                if (allCnt.compareTo(BigDecimal.ZERO) > 0) {
                    winRate = winCnt.divide(allCnt, 2, BigDecimal.ROUND_DOWN).setScale(2, BigDecimal.ROUND_DOWN);
                }
                traderInfoProfit.setWinRate(winRate);
                Date date = new Date();
                DateTime offsetDay = DateUtil.offsetDay(new Date(), -30);
                //30天胜率(30天盈利总单数/30平仓总单数)
src/main/resources/mapper/contract/ContractOrderDao.xml
@@ -84,7 +84,7 @@
        where member_id=#{memberId} and contract_type=2
    </select>
    <select id="selectFollowOrderCntForWinRate" resultType="java.lang.Integer">
    <select id="selectFollowOrderCntForWinRate" resultType="java.math.BigDecimal">
        select count(1)
        from contract_order a
        where member_id=#{memberId}