package com.m2pool.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.m2pool.common.datasource.annotation.DistributionDB;
import com.m2pool.common.datasource.annotation.HashRateDB;
import com.m2pool.manage.dto.*;
import com.m2pool.manage.entity.ManageBroadcast;
import com.m2pool.manage.vo.ManageBaseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Mapper
public interface ManageBroadcastMapper extends BaseMapper<ManageBroadcast> {

    /**
     * 分页查询出用户信息
     * @param coin
     * @param user
     * @param minerUser
     * @return
     */
    List<ManageUserDto> selectUserListByPage(@Param("coin") String coin,@Param("user")String user,@Param("minerUser")  String minerUser);


    /**
     * 管理系统:挖矿账户所有收益金额、时间、状态、转账地址
     * @param user
     * @param coin
     * @return
     */
    List<ManageUserInfoDto> getUserInfo(@Param("user") String user,@Param("coin") String coin, @Param("startDate") Date startDate, @Param("endDate") Date endDate);


    /**
     * 获取挖矿账户对应的历史支付地址
     * @param user
     * @param coin
     * @return
     */
    List<HistoryBalanceDto> getHistoryBalance(@Param("user") String user, @Param("coin") String coin);


    /**
     * 获取用户对应的挖矿账户及币种信息
     * @param user
     * @return
     */
    List<ManageMiningUserDto> getMiningUserInfo(@Param("user") String user);


    /**
     * 用户算力曲线
     * @param minerUser
     * @param coin
     * @return
     */
    List<ManageMiningUserPowerDto>  getMiningPowerInfo(@Param("minerUser") String minerUser, @Param("coin") String coin, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 获取用户对应的所有挖矿账户
     * @param user
     * @param coin
     * @return
     */
    List<String> getAllMinerUserByCoin(@Param("user") String user,@Param("coin") String coin);


    /**
     * 获取挖矿账户对应时间段的在离线情况
     * @param minerUser
     * @param coin
     * @param startDate
     * @param endDate
     * @return
     */
    List<ManageMiningUserOnlineDto> getMinerUserOnlineStatus(@Param("minerUser") String minerUser, @Param("coin") String coin, @Param("startDate") Date startDate, @Param("endDate") Date endDate);


    /**
     * 获取广播信息列表
     * @return
     */
    List<ManageBroadcastDto> getListDataByPage();


    @DistributionDB
    BigDecimal getAccountIncome(@Param("user") String user, @Param("coin") String coin);


    @DistributionDB
    BigDecimal getAccountExpend(@Param("user") String user, @Param("coin") String coin);

    /**
     * 删除1个月前所有在线离线数据
     * @param coin
     * @return
     */
    int deleteOnlineAndOfflineData(@Param("coin") String coin, @Param("date") LocalDateTime date);

    /**
     * 查询需要删除的行数
     * @param coin
     * @return
     */
    int selectNeedDeleteNumbers(@Param("coin") String coin, @Param("date") LocalDateTime date);


    /**
     * 获取起付额
     * @param coin
     * @return
     */
    List<SummaryOfPendingPaymentsDto> getStartPayments(@Param("list")  List<SummaryOfPendingPaymentsDto> summaryOfPendingPaymentsList );
}
